D
D
Danny132020-10-28 17:04:15
webpack
Danny13, 2020-10-28 17:04:15

Why webpack-dev-server stopped following/updating changed css after update?

Everything worked well, but after I updated to the fifth webpack , and updated resp. webpack-dev-server, webpack-dev-server stopped following/updating changed css. That is, when the application is running and I change the html in any file, it immediately sees and updates the changes, but if I change the css file, it does not update anything else.

Here is the script from package.json.
I used to have: "start": "webpack-dev-server --mode development --hot" but I read that webpack serve should now be used . I start , as before, with the npm start command.

"scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "webpack serve --mode development --hot",
        "build": "webpack --mode production"
    },


These are the plugin versions:
"sass": "^1.26.11",
"sass-loader": "^10.0.4",
"style-loader": "^2.0.0",
"webpack": "^5.3.0",
"webpack-cli": "^4.1.0",
"webpack-dev-server": "^3.11.0"


And this is the webpack.congig.js config.
All I added was devServer , since without it it gave an error after the update.
const path = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin")

module.exports = {
    mode: "development",
    entry: "./src/index.js",
    output: {
        path: path.join(__dirname, "/dist"),
        filename: "[name].js",
        sourceMapFilename: "[name].js.map",
    },
    devServer: {
        contentBase: "/dist",
        watchContentBase: true,
        open: true,
        inline: true,
        hot: true,
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: ["babel-loader"],
            },
            {
                test: /\.css$/,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.s[ac]ss$/i,
                use: ["style-loader", "sass-loader"],
            },
            {
                test: /\.(jpe?g|png|gif|woff|woff2|eot|ttf|svg)(\?[a-z0-9=.]+)?$/,
                use: [
                    {
                        loader: "url-loader",
                        options: {
                            limit: 100000,
                        },
                    },
                ],
            },
        ],
    },

    plugins: [
        new HtmlWebpackPlugin({
            template: "./src/index.html",
        }),
    ],
}


Has anyone encountered such a problem?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TechnicaL, 2021-02-06
@TechnicaL

I'm facing the same problem and haven't solved it yet.
You have this problem, how did you solve it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question