我正在尝试建立一个项目,但似乎无法让webpack在保存项目时刷新。
它似乎根本不重新编译bundle.js,而且我已经重新运行脚本以跟踪任何更改。
下面是我的webpack配置和package.json文件中的scripts部分。
webpack.config.js
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = {
entry: "./src/index.js",
mode: "none",
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
test:/\.(s*)css$/,
use:[
'style-loader?sourceMap',
'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'sass-loader'
]
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192&name=images/[name].[ext]',
}
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/templates/index.html"
})
]
};
从package.json运行的脚本
"scripts": {
"build": "webpack",
"dev": "webpack-dev-server --config ./webpack.config.js"
},