Search code examples
javascriptreactjswebwebpackwebpack-dev-server

How to auto run Webpack-dev-server after each save?


I want to auto run and auto refresh webpack-dev-server when I used the package AutoSave OnChange of Atom and run my application.

My webpack-dev-server is :

devServer: {
        contentBase: './src/index.js',
        host: '0.0.0.0',
        compress: true,
        port: 3001, // port number
        historyApiFallback: true,
        quiet: true,
    }

I use the Reactify template, and the scriptsof my package.json is :

"scripts": {
    "start": "webpack-dev-server --mode development --inline --progress",
    "build": "webpack --mode production"
  },

Solution

  • Add a watch flag to your start script.

    "start": "webpack-dev-server --mode development --inline --progress --watch"