summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/neat-seals-fold.md5
-rw-r--r--package.json3
-rw-r--r--packages/astro/src/core/build/static-build.ts3
-rw-r--r--packages/astro/test/fixtures/static-build/package.json7
-rw-r--r--packages/astro/test/fixtures/static-build/pkg/package.json11
-rw-r--r--packages/astro/test/fixtures/static-build/pkg/pkg.js1
-rw-r--r--packages/astro/test/fixtures/static-build/src/pages/index.astro2
-rw-r--r--packages/astro/test/static-build.test.js9
8 files changed, 39 insertions, 2 deletions
diff --git a/.changeset/neat-seals-fold.md b/.changeset/neat-seals-fold.md
new file mode 100644
index 000000000..c34a85d18
--- /dev/null
+++ b/.changeset/neat-seals-fold.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Allow setting ssr Vite config in the static build
diff --git a/package.json b/package.json
index fd47a031c..13312a96b 100644
--- a/package.json
+++ b/package.json
@@ -61,7 +61,8 @@
"docs",
"packages/astro/test/fixtures/builtins/packages/*",
"packages/astro/test/fixtures/builtins-polyfillnode",
- "packages/astro/test/fixtures/custom-elements/my-component-lib"
+ "packages/astro/test/fixtures/custom-elements/my-component-lib",
+ "packages/astro/test/fixtures/static-build/pkg"
],
"volta": {
"node": "14.17.0",
diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts
index bfce0bbf1..a8cd9a785 100644
--- a/packages/astro/src/core/build/static-build.ts
+++ b/packages/astro/src/core/build/static-build.ts
@@ -178,7 +178,8 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
envPrefix: 'PUBLIC_',
server: viteConfig.server,
base: astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/',
- });
+ ssr: viteConfig.ssr,
+ } as ViteConfigWithSSR);
}
async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals, input: Set<string>) {
diff --git a/packages/astro/test/fixtures/static-build/package.json b/packages/astro/test/fixtures/static-build/package.json
new file mode 100644
index 000000000..7cf3a1792
--- /dev/null
+++ b/packages/astro/test/fixtures/static-build/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "@astrojs/test-static-build",
+ "version": "0.0.1",
+ "dependencies": {
+ "@astrojs/test-static-build-pkg": "file:./pkg"
+ }
+}
diff --git a/packages/astro/test/fixtures/static-build/pkg/package.json b/packages/astro/test/fixtures/static-build/pkg/package.json
new file mode 100644
index 000000000..42e6943a5
--- /dev/null
+++ b/packages/astro/test/fixtures/static-build/pkg/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "@astrojs/test-static-build-pkg",
+ "main": "./oops.js",
+ "version": "0.0.1",
+ "exports": {
+ ".": {
+ "import": "./pkg.js",
+ "require": "./oops.js"
+ }
+ }
+}
diff --git a/packages/astro/test/fixtures/static-build/pkg/pkg.js b/packages/astro/test/fixtures/static-build/pkg/pkg.js
new file mode 100644
index 000000000..b013a3b42
--- /dev/null
+++ b/packages/astro/test/fixtures/static-build/pkg/pkg.js
@@ -0,0 +1 @@
+export const test = 'testing';
diff --git a/packages/astro/test/fixtures/static-build/src/pages/index.astro b/packages/astro/test/fixtures/static-build/src/pages/index.astro
index d96024fae..2251cc19f 100644
--- a/packages/astro/test/fixtures/static-build/src/pages/index.astro
+++ b/packages/astro/test/fixtures/static-build/src/pages/index.astro
@@ -1,6 +1,7 @@
---
import MainHead from '../components/MainHead.astro';
import Nav from '../components/Nav/index.jsx';
+import { test as ssrConfigTest } from '@astrojs/test-static-build-pkg';
let allPosts = await Astro.fetchContent('./posts/*.md');
---
<html>
@@ -27,5 +28,6 @@ let allPosts = await Astro.fetchContent('./posts/*.md');
<li><a href={post.url}>post.title</a></li>
))}
</ul>
+<div id="ssr-config">{ssrConfigTest}</div>
</body>
</html>
diff --git a/packages/astro/test/static-build.test.js b/packages/astro/test/static-build.test.js
index e0aee26d2..57598bfd2 100644
--- a/packages/astro/test/static-build.test.js
+++ b/packages/astro/test/static-build.test.js
@@ -16,6 +16,9 @@ describe('Static build', () => {
buildOptions: {
experimentalStaticBuild: true,
},
+ ssr: {
+ noExternal: ['@astrojs/test-static-build-pkg'],
+ },
});
await fixture.build();
});
@@ -94,4 +97,10 @@ describe('Static build', () => {
expect($$(`script[src="${href}"]`).length).to.equal(0, 'no script added to different page');
});
});
+
+ it('honors ssr config', async () => {
+ const html = await fixture.readFile('/index.html');
+ const $ = cheerio.load(html);
+ expect($('#ssr-config').text()).to.equal('testing');
+ });
});