webpack4 watch is slower than 3

config and src is all same
in version3 each watch cost 50ms
but in version4 is cost 400ms+
why?

module.exports={
    entry: "./src/index.js",
    output: {
        path: path.resolve(__dirname, "dist"),
        filename: "brower.js",
        library: "Test",
    },
    node: {
        __filename: false,
        __dirname: false,
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                loader: "babel-loader",
                exclude: /node_modules/,
                options: {
                    presets: [
                        "es2015",
                        "es2016",
                        "es2017",
                        "react",
                        "stage-0",
                        "stage-1",
                        "stage-2",
                        "stage-3",
                    ],
                    plugins: [
                        "static-fs",
                        "version-inline",
                        "transform-decorators",
                        "transform-runtime",
                        "transform-new-target",
                    ],
                },
            },
        ],
    },
    resolve: {
        alias: {
            "": path.resolve(__dirname, "src"),
            "*/../../ES6/src": path.resolve(__dirname, "src"),
        },
        modules: [
            path.resolve(__dirname, "src"),
            "node_modules",
        ],
        extensions: [".js"],
    },
    devtool: "source-map",
    context: __dirname,
    target: "web",
    // profile: false,
    // bail: false,
    cache: true,
    // watch: true,
    watchOptions: {
        aggregateTimeout: 1000,
        ignored: /node_modules/,
    },
};
{
    "babel": {
        "presets": [
            "es2015",
            "es2016",
            "es2017",
            "react",
            "stage-0",
            "stage-1",
            "stage-2",
            "stage-3"
        ]
    },
    "scripts": {
        "build": "gulp run-build",
        "watch": "gulp run-watch"
    },
    "files": [
        "package.json"
    ],
    "dependencies": {},
    "devDependencies": {
        "babel-loader": "7.1.1",
        "babel-cli": "7.0.0-alpha.9",
        "babel-plugin-static-fs": "1.1.0",
        "babel-plugin-version-inline": "1.0.0",
        "babel-preset-es2015": "7.0.0-alpha.9",
        "babel-preset-es2016": "7.0.0-alpha.9",
        "babel-preset-es2017": "7.0.0-alpha.9",
        "babel-preset-react": "7.0.0-alpha.9",
        "babel-preset-stage-0": "7.0.0-alpha.9",
        "babel-preset-stage-1": "7.0.0-alpha.9",
        "babel-preset-stage-2": "7.0.0-alpha.9",
        "babel-preset-stage-3": "7.0.0-alpha.9",
        "babel-plugin-transform-runtime": "7.0.0-alpha.9",
        "babel-plugin-transform-new-target": "7.0.0-alpha.20",
        "chalk": "2.1.0",
        "gulp": "^3.9.1",
        "webpack": "4.6.0",
        "webpack-node-externals": "1.6.0"
    }
}
gulp.task("webpack-watch", [], () => {
    config.watch=true;
    ...

Author: Fantashit

1 thought on “webpack4 watch is slower than 3

  1. You are comparing a dev build (webpack 3) and a production build (webpack 4 defaults mode to production). Add mode: "development" or "none".

Comments are closed.