constant recompiling without changes
Hi,
I'm trying to update my project to webpack 2, but the dev server seems to be recompiling every 200ms or so without any changes to the code.
I have several docker containers running a flask app that is talking to the webpack dev server via nginx. At the moment, my page keeps rapidly reloading and the container logs are outputting the following:
webpack: Compiling...
Hash: e35a96c576a78dd34919
Version: webpack 2.3.3
Time: 205ms
Asset Size Chunks Chunk Names
react_charts.css 5.42 kB 4 [emitted] react_charts
chunk {0} Kadlib.charts.e35a96c576a78dd34919.js (charts) 1.91 MB [entry]
+ 295 hidden modules
chunk {1} Kadlib.chart_search.e35a96c576a78dd34919.js (chart_search) 1.91 MB [entry]
+ 294 hidden modules
chunk {2} Kadlib.chart_all.e35a96c576a78dd34919.js (chart_all) 1.81 MB [entry]
+ 286 hidden modules
chunk {3} Kadlib.utils.e35a96c576a78dd34919.js (utils) 572 kB [entry]
+ 89 hidden modules
chunk {4} Kadlib.react_charts.e35a96c576a78dd34919.js, react_charts.css (react_charts) 304 kB [entry]
+ 88 hidden modules
webpack: Compiled successfully.
webpack: Compiling...
Hash: e35a96c576a78dd34919
Version: webpack 2.3.3
Time: 201ms
Asset Size Chunks Chunk Names
react_charts.css 5.42 kB 4 [emitted] react_charts
chunk {0} Kadlib.charts.e35a96c576a78dd34919.js (charts) 1.91 MB [entry]
+ 295 hidden modules
chunk {1} Kadlib.chart_search.e35a96c576a78dd34919.js (chart_search) 1.91 MB [entry]
+ 294 hidden modules
chunk {2} Kadlib.chart_all.e35a96c576a78dd34919.js (chart_all) 1.81 MB [entry]
+ 286 hidden modules
chunk {3} Kadlib.utils.e35a96c576a78dd34919.js (utils) 572 kB [entry]
+ 89 hidden modules
chunk {4} Kadlib.react_charts.e35a96c576a78dd34919.js, react_charts.css (react_charts) 304 kB [entry]
+ 88 hidden modules
webpack: Compiled successfully.
webpack: Compiling...
I'm fairly new to webpack, so I'm not sure where to go next in terms of debugging; however, this was working in webpack 1.
Here is my webpack config:
var { join, resolve } = require('path');
var webpack = require('webpack');
var ManifestRevisionPlugin = require('manifest-revision-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
const devServerHost = 'http://webpack.dev'
module.exports = {
context: resolve(__dirname),
entry: {
chart_search: './js/chart_search.js',
chart_all: './js/chart_all.js',
charts: './js/kadcharts.js',
utils: './js/utils.js',
react_charts: './css/site.scss'
},
output: {
path: resolve(__dirname, 'build'),
filename: 'Kadlib.[name].[hash].js',
publicPath: devServerHost + '/static/'
},
module : {
rules: [
{
test: /\.jsx?$/i,
use: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.s?css$/i,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader']
}),
exclude: /node_modules/
},
{
test: /\.(gif|jpe?g|png|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {}
}
],
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new ExtractTextPlugin('react_charts.css'),
new ManifestRevisionPlugin(join('build', 'manifest.json'), {
rootAssetPath: 'build'
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin()
],
devServer: {
contentBase: resolve(__dirname, 'build'),
hot: true,
inline: true,
host: '0.0.0.0',
port: 2992,
}
};
and here is the package.json:
{
"name": "kaddash",
"version": "1.0.0",
"description": "dashboard",
"main": "index.js",
"scripts": {
"clean": "rimraf build",
"build": "NODE_ENV=production yarn run clean && webpack -p",
"serve": "webpack-dev-server"
},
"dependencies": {
"d3": "^4.7.4",
"fuse.js": "^2.6.2",
"jquery": "^3.2.1",
"react": "^15.5.3",
"react-dom": "^15.5.3",
"react-redux": "^5.0.4",
"react-select-search": "^0.5.5",
"redux": "^3.6.0",
"yarn": "^0.22.0"
},
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-env": "^1.3.2",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.0",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.11.1",
"image-webpack-loader": "^3.3.0",
"manifest-revision-webpack-plugin": "^0.4.0",
"node-sass": "^4.5.2",
"react-hot-loader": "next",
"rimraf": "^2.6.1",
"sass-loader": "^6.0.3",
"style-loader": "^0.16.1",
"webpack": "^2.3.3",
"webpack-dev-server": "^2.4.2"
}
}
Thanks in advance for any thoughts or help.
Can you plz try removing ExtractTextPlugin for development mode?
Hi msathis,
Thanks for the tip. I removed the ExtractTextPlugin, but it didn't seem to help. However, that got me thinking that it might be related to the flask manifest plugin (manifest-revision-webpack-plugin). Sure enough, removing that seemed to fix the constant recompiling, but it also breaks updating the file names in the Jinja templates.
It's possible that the manifest plugin isn't the root issue, so I'll look into using HtmlWebpackPlugin with Jinja and see if that works instead.
@owenvallis : The webpack recompiles every millisecond only when I search for any string in the whole project (ctrl+shift+f) in my atom editor. Why is that so?
when it has the same name from entry to out it will compile without changing but when you try change the output name it will not compile again. same what happened to me. but i want to have the same name. how to make it like that?
Constant compile without changing the code
var webpack = require('webpack'); var path = require('path');
module.exports = {
context: __dirname + "/assets",
entry: "./js/main.js",
output: {
path: path.resolve(__dirname + "/dist/js"),
filename: "[name].js"
}
};
it will work if not same name
var webpack = require('webpack'); var path = require('path');
module.exports = {
context: __dirname + "/assets",
entry: "./js/main.js",
output: {
path: path.resolve(__dirname + "/dist/js"),
filename: "bundle.js"
}
};
I was facing the same issue. I upgraded yarn using yarn upgrade and the issue seemed to go away.
Our team faced with this too about month ago without any changes into config or webpack package. I think it related to, in our case, Windows update or Visual Studio Code. We noticed that opening file was enough to trigger rebuild.