@sveltejs/adapter-vercel 1.0.0-next.42 → 1.0.0-next.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +20 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFileSync } from 'fs';
|
|
1
|
+
import { existsSync, writeFileSync } from 'fs';
|
|
2
2
|
import { posix } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import esbuild from 'esbuild';
|
|
@@ -102,7 +102,7 @@ export default function ({ external = [] } = {}) {
|
|
|
102
102
|
|
|
103
103
|
builder.log.minor('Prerendering static pages...');
|
|
104
104
|
|
|
105
|
-
await builder.prerender({
|
|
105
|
+
const prerendered = await builder.prerender({
|
|
106
106
|
dest: `${dir}/static`
|
|
107
107
|
});
|
|
108
108
|
|
|
@@ -143,10 +143,28 @@ export default function ({ external = [] } = {}) {
|
|
|
143
143
|
builder.log.minor('Writing routes...');
|
|
144
144
|
|
|
145
145
|
builder.mkdirp(`${dir}/config`);
|
|
146
|
+
|
|
147
|
+
const prerendered_routes = prerendered.paths
|
|
148
|
+
.map((path) => {
|
|
149
|
+
const file =
|
|
150
|
+
path === '/'
|
|
151
|
+
? '/index.html'
|
|
152
|
+
: path + (builder.trailingSlash === 'always' ? '/index.html' : '.html');
|
|
153
|
+
|
|
154
|
+
if (existsSync(`${dir}/static${file}`)) {
|
|
155
|
+
return {
|
|
156
|
+
src: path,
|
|
157
|
+
dest: file
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
.filter(Boolean);
|
|
162
|
+
|
|
146
163
|
writeFileSync(
|
|
147
164
|
`${dir}/config/routes.json`,
|
|
148
165
|
JSON.stringify([
|
|
149
166
|
...redirects[builder.trailingSlash],
|
|
167
|
+
...prerendered_routes,
|
|
150
168
|
{
|
|
151
169
|
src: `/${builder.appDir}/.+`,
|
|
152
170
|
headers: {
|