我有一个问题,当我更改src js或scss时,如果我更改dist文件夹文件并在"build": "webpack --mode production"
时也可以刷新,则正在运行的dev服务器中什么也不会发生。在我的package.json中,我有"start": "webpack-dev-server --mode development --open --hot"
个依赖项:"webpack": "^4.15.1", webpack-cli": "^3.0.8, webpack-dev-server": "^3.1.4
。
我也在使用Silverstripe 3.7.1-rc1
我的webpack配置文件如下:
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const env = process.env.NODE_ENV;
const isDevelopment = process.env.NODE_ENV !== 'production';
module.exports = {
entry: "./src/index.js",
output: {
path: path.join(__dirname, "/dist"),
filename: "index_bundle.js"
},
devServer: {
public: 'localhost:9743/able_ss3',
contentBase: path.join(__dirname, "/dist"),
port: 9743,
proxy: {
'/able_ss3': {
target: "http://localhost:80"
}
},
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.(scss|css)$/,
use: [
MiniCssExtractPlugin.loader, "css-loader", "postcss-loader", "sass-loader"
],
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name]-styles.css",
chunkFilename: "[id].css"
})
]
};