webpack-dev-server 只自动更新JS文件 其它不更新
我修改less 文件 chrome 控制台有提示:
[WDS] Hot Module Replacement enabled.
2app.bundle.js?385c225…:1102 [WDS] App updated. Recompiling...
app.bundle.js?385c225…:1245 [WDS] App hot update...
app.bundle.js?385c225…:754 [HMR] Checking for updates on the server...
app.bundle.js?385c225…:754 [HMR] Nothing hot updated.
app.bundle.js?385c225…:754 [HMR] App is up to date.
但就是不更新, 修改js文件就可以
下面是我写的代码
package.json:
{
"name": "webpacktest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack-dev-server --content-base ./ --open --inline --hot --compress",
"build": "webpack -d --watch"
},
"author": "",
"license": "ISC",
"dependencies": {
"webpack": "^3.10.0"
},
"devDependencies": {
"babel-loader": "^7.1.3",
"css-loader": "^0.28.10",
"extract-text-webpack-plugin": "^3.0.2",
"happypack": "^4.0.1",
"html-webpack-plugin": "^3.0.4",
"less": "^3.0.1",
"less-loader": "^4.0.6",
"sass": "^1.0.0-beta.5.3",
"sass-loader": "^6.0.7",
"style-loader": "^0.20.2",
"webpack-dev-server": "^2.11.2"
}
}
webpack.config.js :
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: './src/app.js',
output: {
path: __dirname + '/dist',
filename: 'app.bundle.js'
//publicPath: '/dist'
},
plugins: [
new HtmlWebpackPlugin({
minify: {
collapseWhitespace: true,
},
hash: true,
}),
new ExtractTextPlugin('style.css')
],
module: {
rules: [
{
test: /\.less$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'less-loader']
}),
}
]
},
devServer: {
port: 9000
}
};
app.js :
import css from './app.less';
console.log('hello world');
document.body.innerHTML = 'hello world';
app.less :
@base: #000;
body {
background: @base;
color: #fff
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里没人吗 要石沉大海了??