当我更改html或CSS文件时,浏览器不会刷新。重新启动服务器时,我只会看到更改。更改文件后如何使它自动刷新?
我尝试在package.json
中更改webpack-dev-server的版本,但这似乎不起作用。
这是我的webpack.config.js
const path = require('path');
const config = require('./site.config');
const loaders = require('./webpack.loaders');
const plugins = require('./webpack.plugins');
module.exports = {
context: path.join(config.root, config.paths.src),
entry: [
path.join(config.root, config.paths.src, 'javascripts/scripts.js'),
path.join(config.root, config.paths.src, 'stylesheets/styles.scss'),
],
output: {
path: path.join(config.root, config.paths.dist),
filename: '[name].[hash].js',
},
mode: ['production', 'development'].includes(config.env)
? config.env
: 'development',
devtool: config.env === 'production'
? 'hidden-source-map'
: 'cheap-eval-source-map',
devServer: {
contentBase: path.join(config.root, config.paths.src),
watchContentBase: true,
hot: true,
open: true,
port: config.port,
host: config.dev_host,
},
module: {
rules: loaders,
},
plugins,
};