build: {
env: require("./prod.env"),
index: path.resolve(__dirname, "../dist/index.html"),
assetsRoot: path.resolve(__dirname, "../dist"),
assetsSubDirectory: "static",
assetsPublicPath: "/",
productionSourceMap: true,
productionGzip: false,
productionGzipExtensions: ["js", "css"]
}
assetsPublicPath:"/", should be the path to set static resources, right? It has nothing to do with index.html "s position, does it?
the problem now is that when I access the index.js in the root directory of the server, the page is normal, but when I open it in another location, it is blank, and there is no error. How to solve this problem?
in addition, how to configure the html generated after, npm run build to be accessed locally?
answer: in the new scaffolding, a distinction has actually been made between the assetsPublicPath of the production environment and the local environment
build: {
env: require("./prod.env"),
index: path.resolve(__dirname, "../dist/index.html"),
assetsRoot: path.resolve(__dirname, "../dist"),
assetsSubDirectory: "static",
assetsPublicPath: "/XXX/", //
...
},
dev: {
env: require("./dev.env"),
port: 8080,
assetsSubDirectory: "static",
assetsPublicPath: "/",
...
}