1. There is a simple (there is only one console.log ) script script.js , which I package with a webpack into a module and write to main.bundle.js
  2. if you change the contents of script.js , and run the webpack webpack then the module builds with the new code.
  3. if you change the contents of script.js , and run the webpack webpack-dev-server command, the module also builds with the new code. BUT! When I make changes to the source file or delete the compiled file, the changes are not applied and the new file is not created, even though it writes to the console:

     webpack: Compiling... Hash: 30798a2a1b23da35b30a Version: webpack 2.4.1 Time: 40ms Asset Size Chunks Chunk Names main.bundle.js 317 kB 0 [emitted] [big] main chunk {0} main.bundle.js (main) 303 kB [entry] [rendered] [35] ./client/dev/script.js 17 bytes {0} [built] + 86 hidden modules webpack: Compiled successfully. 

here is my webpack.config.js :

 const webpack = require('webpack'); const path = require('path'); module.exports = { entry: './client/dev/script.js', output: { path: path.resolve(__dirname, './client/public/js/'), filename: '[name].bundle.js' }, devServer: { hot: true, contentBase: "./client/public/", port: 6611, } }; 

module versions:

  • "webpack": "2.4.1",
  • "webpack-dev-server": "2.4.2"

Question: What does he lack? Why doesn’t a rebuild happen when a file's contents change?

    1 answer 1

    Add to your webpack.config.js watch: true option watch: true
    https://webpack.js.org/configuration/watch/#components/sidebar/sidebar.jsx