При запуске командой npm start запускается браузер, но при изменение стилей и скриптов, страница не обновляется.
webpack.config.js:
const path = require('path')
const HTMLWebpackPlugin = require('html-webpack-plugin')
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
// const devMode = process.env.NODE_ENV !== 'production';
module.exports = {
devServer: {
port: 9000,
},
context: path.resolve(__dirname, 'src'),
mode: "development",
entry: {
main: './index.js',
analytics: './analytics.js'
},
output: {
filename: "./scripts/[name].[contenthash].js",
path: path.resolve(__dirname, 'dist')
},
plugins: [
new HTMLWebpackPlugin({
template: "./index.html",
inject: 'body'
}),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: "./styles/[name].[contenthash].css",
})
],
module: {
rules: [
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.s[ac]ss$/i,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
},
]
}
}
package.json:
{
"name": "localhost",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production",
"watch": "webpack --mode development --watch",
"start": "webpack-dev-server --open"
},
"author": "",
"license": "ISC",
"devDependencies": {
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.7.1",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.6.0",
"node-sass": "^7.0.1",
"sass-loader": "^12.6.0",
"style-loader": "^3.3.1",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.8.1"
}
}