Repository navigation
Closed
Description
I apologize if I I should be posting this on the main webpack repo instead of here. If that's the case, let me know and I'll move it.
- Operating System: Mac OS High Sierra
- Node Version: 8.10.0
- NPM Version: 5.6.0
- webpack Version: 4.1.1
- webpack-dev-server Version: 3.1.1
- This is a bug
- This is a modification request
Code
Note that the webpack file I posted isn't exactly what we have, but anything removed was just company info, me merging a common webpack file with our dev one to produce a single code snippet, and removing some unrelated/redundant info (e.g. multiple templates with similar content).
// webpack.config.js
const webpack = require('webpack');
const merge = require('webpack-merge');
const config = require('./webpack.common.config.js');
const Jarvis = require('webpack-jarvis');
module.exports = merge(config, {
mode: 'development',
devtool: 'cheap-module-eval-source-map',
output: {
publicPath: '/',
filename: '[name]-[hash].js',
crossOriginLoading: 'anonymous',
chunkFilename: '[name]-[hash].js'
},
optimization: {
noEmitOnErrors: true,
namedModules: true,
},
plugins: [
new CopyWebpackPlugin([{
from: 'app/assets/images/favicon/',
to: 'favicon/',
}]),
new CopyWebpackPlugin([{
from: 'app/assets/images/square/logo.png',
to: 'logo.png',
}]),
new ExtractTextPlugin({
filename: '[name]-styles-[contenthash].css',
allChunks: true,
}),
new DeterministicHash(),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new HtmlWebpackPlugin({
template: 'templates/index.ejs',
filename: 'index.html',
inject: false,
chunks: ['common', 'main'],
appleTouchIconSizes: [57, 72, 114, 120, 144, 152],
}),
new Jarvis({port: 7003}),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
_DEVELOPMENT_: true,
})
],
module: {
rules: [
{
test: /\.(otf|ttf|woff|woff2|png|jpg|svg|mp3|wav|aff|dic)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'assets/[name]-[sha1:hash:hex:8].[ext]'
},
},
]
},
{
test: /\.s?css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: () => [
require('precss'),
require('autoprefixer'),
]
}
},
'sass-loader'
]
}),
},
{
test: /\.jsx?$/,
use: ['babel-loader'],
},
]
},
entry: {
main: [
'babel-polyfill',
'react-hot-loader/patch',
'webpack/hot/only-dev-server',
'webpack-dev-server/client?https://0.0.0.0:7001',
'./app/main.js',
],
}
}); // dev-server.js
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.devconfig');
const ssl = require('./devssl');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
headers: {'Access-Control-Allow-Origin': '*'},
hot: true,
https: true,
clientLogLevel: 'error',
cert: ssl.cert,
overlay: true,
key: ssl.key,
historyApiFallback: true,
disableHostCheck: true,
watchOptions: {
ignored: /\/node_modules\/.*/,
},
stats: {
assets: false,
cached: false,
cachedAssets: false,
children: false,
chunks: false,
chunkModules: false,
chunkOrigins: false,
colors: true,
depth: false,
entrypoints: true,
excludeAssets: /app\/assets/,
hash: false,
maxModules: 15,
modules: false,
performance: true,
reasons: false,
source: false,
timings: true,
version: false,
warnings: true,
},
}).listen(7001, '0.0.0.0', function(err, result) {
console.log(`Serving chunks at path ${config.output.publicPath}`);
});Expected Behavior
Similar, if not faster HMR
Actual Behavior
Hot reload time increased from ~5s to ~10s when upgrading to Webpack 4.
For Bugs; How can we reproduce the behavior?
Unsure if it reproduces in every case, but in our case we have a large webapp that spits out multiple entry points, with sass processing, along with a lot of other webpack features.
Reacted by Vlad Derzhavin, patrikx3, Etienne, Searene, J Wylie Woodcock, Su, degres, Mohammad Arif, Vladimir Vujosevic, clodal and 18 more
Reacted by Luca Fagioli
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
None yet
Activity
benwilkes9 commentedon Mar 14, 2018
I'm also experiencing this issue - just upgraded to web pack 4 and hot reload times have increased considerably
SpaceK33z commentedon Mar 15, 2018
I can't fix this in webpack-dev-server, nearly everything regarding to HMR is done in webpack itself, WDS only serves it through a server.
drewjenkins commentedon Mar 15, 2018
I kind of thought that may be the case. I'll move this issue over to the main webpack repo :)
For anyone else running into this, here's a link to the issue I created on the main Webpack repo webpack/webpack#6767
p3x-robot commentedon Apr 18, 2018
Same here, can't work Webpack anymore (just like UglifyJs3 about 4 times slower), looks the same with Webpack case.
kulicuu commentedon May 25, 2018
Same here, first time using Webpack since February, and I thought the
-wwatch was broken, but it's just building slow.ajain17 commentedon Mar 15, 2019
I had the same issue with Webpack version 4.27.1 and Node V8, V10. I just upgraded my node version to 11.11.0 and my initial build is down from 2 mins to 1min and HMR time is down from 2 mins to 12 seconds.
gagangoku commentedon May 10, 2019
Did you try using --mode=development for dev builds ? It's quite fast for me: https://medium.com/@gagan_goku/hot-reloading-a-react-app-with-ssr-eb216b5464f1