vue项目中,npm run build生成的文件只能放在服务器根目录下才能生效,放在其他目录下页面空白,也不报错,怎么解决?
查了相关资料,对config下的index.js文件的assetsPublicPath值也做了对应修改,可是还是不行。希望大家帮帮我,帮我实现我的需求,我希望可以把打包生成的项目通过 'www.example.com/a/b/'来访问项目主页。
build: {
env: require("./prod.env"),
index: path.resolve(__dirname, "../dist/index.html"),
assetsRoot: path.resolve(__dirname, "../dist"),
assetsSubDirectory: "static",
//assetsPublicPath: "/", 修改之前
assetsPublicPath: "./", //修改之后
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ["js", "css"]
}
可以放到任意路径,你得自己改改路径
build完之后,全是静态文件,路径对了就好了