So, I installed webpack and webpack-dev-server , but webpack-dev-server does not restart automatically. If I modify the file and save it, there will be no changes in the browser until I manually multiply it.
Here is my webpack configurator and my script file that runs webpack-dev-server . Does anyone see anything that could interfere with the automatic reboot?
I combined them by reading several manuals, documents, and reading react-create-app files.
config /webpack.config.dev.js
'use strict'; const ExtractTextPlugin = require('extract-text-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const autoprefixer = require('autoprefixer'); const webpack = require('webpack'); const extractSass = new ExtractTextPlugin('style.css'); module.exports = { entry : './src/index.jsx', eslint: {configFile: './src/.eslintrc.json'}, module: { loaders: [ { exclude: /node_modules/, include: ['src'], loader: 'babel', test : /(\.js|\.jsx)$/ }, { exclude: /node_modules/, include: ['src'] loader : extractSass.extract([ 'css', 'postcss', 'sass' ]), test : /\.scss$/ } ], preLoaders: [ { exclude: /node_modules/, loader : 'eslint', query : {presets: [ 'react', 'latest' ]}, test : /(\.js|\.jsx)$/ } ] }, output: { filename : 'bundle.js', path : 'dist', publicPath: '/' }, plugins: [ extractSass, new HtmlWebpackPlugin({ inject : true, template: paths.appHtml }), new webpack.HotModuleReplacementPlugin({multistep: true}) ], postcss: () => [ autoprefixer({ browsers: [ '>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9' ] }) ] };
Scripts /dev.js
do $ yarn run dev
'use strict'; const WebpackDevServer = require('webpack-dev-server'); const config = require('../config/webpack.config.dev.js'); const webpack = require('webpack'); const compiler = webpack(config); const server = new WebpackDevServer(compiler, { clientLogLevel : 'warn', compress : true, contentBase : 'public', filename : config.output.filename, historyApiFallback: true, hot : true, inline : true, lazy : false, noInfo : true, publicPath : '/', quiet : true, stats : 'errors-only', watchOptions : { aggregateTimeout: 300, poll : 1000 } }); server.listen(8080, 'localhost', () => { console.log('Listening on port 8080'); });