Skip to content

Instantly share code, notes, and snippets.

@teekaay
Last active July 11, 2017 18:06
Show Gist options
  • Save teekaay/fc207a7a11cb1b84dba8ef4705eea91b to your computer and use it in GitHub Desktop.
Save teekaay/fc207a7a11cb1b84dba8ef4705eea91b to your computer and use it in GitHub Desktop.
Hanging webpack
{
"name": "webpack-hangs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "teekaay",
"license": "MIT",
"scripts": {
"start": "node app.js",
"test": "./node_modules/.bin/jest",
"test:watch": "npm run test -- --watch",
"test:coverage": "npm run test -- --cov",
"lint": "./node_modules/.bin/eslint --format table src/**/*.js",
"bundle:hot": "./node_modules/.bin/webpack-dashboard -- ./node_modules/.bin/webpack-dev-server --content-base ./",
"bundle:prod": "./node_modules/.bin/webpack",
"bundle:profile": "npm run bundle:prod -- --profile --json > reports/build-stats.json"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-jest": "^20.0.3",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"enzyme": "^2.9.1",
"eslint": "^4.2.0",
"eslint-plugin-react": "^7.1.0",
"jest": "^20.0.4",
"jest-enzyme": "^3.4.0",
"react-addons-test-utils": "^15.6.0",
"react-hot-loader": "^1.3.1",
"react-test-renderer": "^15.6.1",
"webpack": "2.5.1",
"webpack-dashboard": "^0.4.0",
"webpack-dev-server": "^2.5.1"
},
"babel": {
"presets": [
"es2015",
"stage-2",
"react"
]
},
"jest": {
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",
"unmockedModulePathPatterns": [
"react",
"enzyme",
"jest-enzyme"
],
"testRegex": ".*.spec.js",
"verbose": true,
"bail": true,
"notify": true
}
}
#!/bin/sh
# Hangs
NODE_ENV=production ./node_modules/.bin/webpack -p --progress
# Does not hang -> Finishes after a minute
NODE_ENV=production ./node_modules/.bin/webpack-dashboard -- ./node_modules/.bin/webpack -p --progress
const path = require('path');
const webpack = require('webpack');
const package = require('./package.json');
const DashboardPlugin = require('webpack-dashboard/plugin');
// Configuration
const buildDir = path.resolve('./dist');
const srcDir = path.resolve('./app');
const isProduction = process.env.NODE_ENV === 'production';
const config = {
entry: path.join(srcDir, 'index.js'),
devtool: isProduction ? 'eval' : 'source-map',
output: {
path: buildDir,
filename: 'bundle.js',
publicPath: '/dist',
},
resolve: {
extensions: ['.js'],
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['react-hot-loader', 'babel-loader'],
},
],
},
devServer: {
port: 7070,
host: 'localhost',
hot: true,
inline: true,
historyApiFallback: true,
proxy: {
},
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new DashboardPlugin(),
],
};
if(isProduction === false) {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
}
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment