next js 静态构建和下载 本地打开html
在下一个js静态构建之后,css js路径以'file:///'开头
我想更改路径
-- next.config.js
/** @type {import('next').NextConfig} */
const path = require('path');
const nextConfig = {
output: 'export',
reactStrictMode: false,
images: {
loader: "custom",
loaderFile: "localImageLoader.js"
},
webpack(config, options) {
config.resolve.modules.push(path.resolve("./"));
return config;
},
}
module.exports = nextConfig
我也尝试过 assetprfix: "./" 或 basepath: "./",但出现错误,因为它们不是以 / 开头。
试试这个
const nextConfig = {
output: 'export',
reactStrictMode: false,
images: {
loader: 'custom',
loaderFile: 'localImageLoader.js',
},
assetPrefix: '', // Set to '' for relative paths, or a specific URL base if needed
basePath: '', // No base path
webpack(config, options) {
config.resolve.modules.push(path.resolve('./'));
return config;
},
};
module.exports = nextConfig;
参考链接