@netlify/plugin-nextjs 4.2.5 → 4.2.6
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/lib/helpers/files.js +17 -12
- package/lib/index.js +1 -1
- package/package.json +2 -2
package/lib/helpers/files.js
CHANGED
|
@@ -63,7 +63,7 @@ const getMiddleware = async (publish) => {
|
|
|
63
63
|
};
|
|
64
64
|
exports.getMiddleware = getMiddleware;
|
|
65
65
|
// eslint-disable-next-line max-lines-per-function
|
|
66
|
-
const moveStaticPages = async ({ netlifyConfig, target, i18n, }) => {
|
|
66
|
+
const moveStaticPages = async ({ netlifyConfig, target, i18n, basePath, }) => {
|
|
67
67
|
console.log('Moving static page files to serve from CDN...');
|
|
68
68
|
const outputDir = (0, pathe_1.join)(netlifyConfig.build.publish, target === 'server' ? 'server' : 'serverless');
|
|
69
69
|
const root = (0, pathe_1.join)(outputDir, 'pages');
|
|
@@ -94,9 +94,10 @@ const moveStaticPages = async ({ netlifyConfig, target, i18n, }) => {
|
|
|
94
94
|
const isData = file.endsWith('.json');
|
|
95
95
|
const source = (0, pathe_1.join)(root, file);
|
|
96
96
|
const targetFile = isData ? (0, pathe_1.join)(dataDir, file) : file;
|
|
97
|
+
const targetPath = basePath ? (0, pathe_1.join)(basePath, targetFile) : targetFile;
|
|
97
98
|
files.push(file);
|
|
98
|
-
filesManifest[file] =
|
|
99
|
-
const dest = (0, pathe_1.join)(netlifyConfig.build.publish,
|
|
99
|
+
filesManifest[file] = targetPath;
|
|
100
|
+
const dest = (0, pathe_1.join)(netlifyConfig.build.publish, targetPath);
|
|
100
101
|
try {
|
|
101
102
|
await (0, fs_extra_1.move)(source, dest);
|
|
102
103
|
}
|
|
@@ -190,19 +191,23 @@ const moveStaticPages = async ({ netlifyConfig, target, i18n, }) => {
|
|
|
190
191
|
// Write the manifest for use in the serverless functions
|
|
191
192
|
await (0, fs_extra_1.writeJson)((0, pathe_1.join)(netlifyConfig.build.publish, 'static-manifest.json'), Object.entries(filesManifest));
|
|
192
193
|
if (i18n === null || i18n === void 0 ? void 0 : i18n.defaultLocale) {
|
|
194
|
+
const rootPath = basePath ? (0, pathe_1.join)(netlifyConfig.build.publish, basePath) : netlifyConfig.build.publish;
|
|
193
195
|
// Copy the default locale into the root
|
|
194
|
-
const defaultLocaleDir = (0, pathe_1.join)(
|
|
196
|
+
const defaultLocaleDir = (0, pathe_1.join)(rootPath, i18n.defaultLocale);
|
|
195
197
|
if ((0, fs_extra_1.existsSync)(defaultLocaleDir)) {
|
|
196
|
-
await (0, fs_extra_1.copy)(defaultLocaleDir, `${
|
|
198
|
+
await (0, fs_extra_1.copy)(defaultLocaleDir, `${rootPath}/`);
|
|
197
199
|
}
|
|
198
|
-
const defaultLocaleIndex = (0, pathe_1.join)(
|
|
199
|
-
const indexHtml = (0, pathe_1.join)(
|
|
200
|
+
const defaultLocaleIndex = (0, pathe_1.join)(rootPath, `${i18n.defaultLocale}.html`);
|
|
201
|
+
const indexHtml = (0, pathe_1.join)(rootPath, 'index.html');
|
|
200
202
|
if ((0, fs_extra_1.existsSync)(defaultLocaleIndex) && !(0, fs_extra_1.existsSync)(indexHtml)) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
203
|
+
await (0, fs_extra_1.copy)(defaultLocaleIndex, indexHtml, { overwrite: false }).catch(() => {
|
|
204
|
+
/* ignore */
|
|
205
|
+
});
|
|
206
|
+
await (0, fs_extra_1.copy)((0, pathe_1.join)(rootPath, `${i18n.defaultLocale}.json`), (0, pathe_1.join)(rootPath, 'index.json'), {
|
|
207
|
+
overwrite: false,
|
|
208
|
+
}).catch(() => {
|
|
209
|
+
/* ignore */
|
|
210
|
+
});
|
|
206
211
|
}
|
|
207
212
|
}
|
|
208
213
|
if (shortRevalidateRoutes.length !== 0) {
|
package/lib/index.js
CHANGED
|
@@ -49,7 +49,7 @@ const plugin = {
|
|
|
49
49
|
console.log("The flag 'EXPERIMENTAL_MOVE_STATIC_PAGES' is no longer required, as it is now the default. To disable this behavior, set the env var 'SERVE_STATIC_FILES_FROM_ORIGIN' to 'true'");
|
|
50
50
|
}
|
|
51
51
|
if (!process.env.SERVE_STATIC_FILES_FROM_ORIGIN) {
|
|
52
|
-
await (0, files_1.moveStaticPages)({ target, netlifyConfig, i18n });
|
|
52
|
+
await (0, files_1.moveStaticPages)({ target, netlifyConfig, i18n, basePath });
|
|
53
53
|
}
|
|
54
54
|
await (0, redirects_1.generateStaticRedirects)({
|
|
55
55
|
netlifyConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.6",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@babel/core": "^7.15.8",
|
|
76
76
|
"@babel/preset-env": "^7.15.8",
|
|
77
77
|
"@babel/preset-typescript": "^7.16.0",
|
|
78
|
-
"@netlify/build": "^26.
|
|
78
|
+
"@netlify/build": "^26.3.1",
|
|
79
79
|
"@netlify/eslint-config-node": "^5.1.4",
|
|
80
80
|
"@reach/dialog": "^0.16.2",
|
|
81
81
|
"@reach/visually-hidden": "^0.16.0",
|