I am using webpack to manage my web application and using webpack-dev-server for development web server. I know that webpack dev server has a --watch switch to watch the content of source code change. But when I run webpack-dev-server --watch command and then change the source code, it doesn't reload the source code. I have to shutdown the server then run webpack command to re-bundle my target file. Below is my webpack-config.js file which has watch: true configuration. I don't understand why webpack-dev-server can't watch the source code changes.
module.exports = {
entry: {
app: PATHS.app
},
output: {
path: PATHS.build,
filename: 'app.bundle.js',
},
watch: true,
resolve: {
extensions: ['', '.js', '.jsx','.css'],
modulesDirectories: ['node_modules'],
alias: {
leaflet_css: __dirname + '/node_modules/leaflet/dist/leaflet.css',
normalize_css: __dirname + '/node_modules/normalize.css/normalize.css',
main_css: __dirname + '/src/style/main.css'
}
},
module: {
// preLoaders: [
// {
// test: /\.js$/,
// loader: "source-map-loader"
// }
// ],
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader?presets=es2015'
},
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.png$/, loader: "url-loader?limit=100000" },
{ test: /\.jpg$/, loader: "file-loader" },
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel-loader?presets=es2015']
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
output: {
comments: false,
},
}),
new NpmInstallPlugin({
save: true // --save
})
],
devServer: {
colors: true,
contentBase: __dirname,
historyApiFallback: true,
hot: true,
inline: true,
port: 8081,
progress: true,
stats: {
cached: false
}
}
import style from 'leaflet_css'; Is there anything in style variable? - Artem Markov