gpt4 book ai didi

Webpack-dev-server 提供旧文件内容

转载 作者:行者123 更新时间:2023-12-05 00:56:45 24 4
gpt4 key购买 nike

我有一个非常简单的项目:

appdir
+- app
+- main.js
+- build
+- bundle.js
+- index.html
+- webpack.config.js

webpack.config.js:

var path=require("path");

module.exports = {
entry: path.resolve(__dirname, "./app/main.js"),
output: {
path: path.resolve(__dirname, "build"),
filename: "bundle.js"
}
};

我换了之后 main.js ,webpack-dev-server 似乎检测到更改并执行重新捆绑 bundle.js ,但浏览器仍然收到 main.js 的旧内容.

我通过执行 webpack-dev-server webpack.config.js 启动服务器

有任何想法吗?

最佳答案

调查https://github.com/webpack/webpack-dev-server/issues/24 , 我添加了 publicPathwebpack.config.js并且 webpack 现在提供包含新内容的包 ^_^

var path=require("path");

module.exports = {
entry: path.resolve(__dirname, "./app/main.js"),
output: {
path: path.resolve(__dirname, "build"),
filename: "bundle.js",
publicPath: "/build/",
},
devServer: {
}
};

关于Webpack-dev-server 提供旧文件内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35835698/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com