我目前正在使用webpack-vue模板构建我的应用程序(链接:https://github.com/vuejs-templates/webpack),但我遇到了一些问题。
因为我需要将我的构建与后端框架(可能是php-laravel)集成,所以我想测试一下这个包。问题是webpack生成的文件static / index.html会抛出一些错误:
index.html:1 GET file:///static/css/app.96d14fbf18e5bfb68fd0f9edce92c47a.css net::ERR_FILE_NOT_FOUND
index.html:1 GET file:///static/js/manifest.a4398cfdc7137ae839bb.js net::ERR_FILE_NOT_FOUND
index.html:1 GET file:///static/js/vendor.e9845cb55d3e0c57edf6.js net::ERR_FILE_NOT_FOUND
index.html:1 GET file:///static/js/app.436c8ff4536e93d010e6.js net::ERR_FILE_NOT_FOUND
将/ static更改为./static就足以解决这个问题,但我不明白为什么webpack本身无法解决这个问题。 这是我的config / index.js文件:
var path = require("path")
module.exports = {
build: {
env: require("./prod.env"),
index: path.resolve(__dirname, "../dist/index.html"),
assetsRoot: path.resolve(__dirname, "../dist"),
assetsSubDirectory: "static",
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"],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
},
dev: {
env: require("./dev.env"),
port: 8081,
autoOpenBrowser: true,
assetsSubDirectory: "static",
assetsPublicPath: "./",
proxyTable: {},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
}
}
问题出在哪里?我没有触及该文件(但是端口号从8080到8081)......