Skip to content

Commit

Permalink
Merge pull request #98 from plone/webpack4
Browse files Browse the repository at this point in the history
Upgrade to Webpack 4.
  • Loading branch information
robgietema committed Mar 12, 2018
2 parents 8281d7c + ee8ccbc commit d1ebf96
Show file tree
Hide file tree
Showing 6 changed files with 1,061 additions and 266 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* Added commenting @robgietema
* Added tags @robgietema
* Upgrade to React 16 @sneridagh
* Upgrade to Webpack 4 @sneridagh

## 0.4.0 (2017-05-03)

Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@
"url-loader": "1.0.1",
"uuid": "3.2.1",
"warning": "3.0.0",
"webpack": "3.10.0"
"webpack": "4.1.1",
"webpack-cli": "2.0.11"
},
"devDependencies": {
"autoprefixer-loader": "3.2.0",
Expand Down Expand Up @@ -259,13 +260,13 @@
"eslint-plugin-react": "7.7.0",
"estraverse": "4.2.0",
"estraverse-fb": "1.3.2",
"extract-text-webpack-plugin": "3.0.2",
"extract-text-webpack-plugin": "4.0.0-beta.0",
"flow-bin": "0.67.1",
"image-webpack-loader": "4.1.0",
"jest": "22.4.2",
"jsdoc": "3.5.5",
"json-loader": "0.5.7",
"node-sass": "4.7.2",
"node-sass": "4.8.1",
"nodemon": "1.17.1",
"npm-run-all": "4.1.2",
"react-a11y": "1.0.0",
Expand All @@ -288,7 +289,7 @@
"supertest-as-promised": "4.0.2",
"timekeeper": "2.0.0",
"webpack-bundle-analyzer": "2.11.1",
"webpack-dev-middleware": "2.0.4",
"webpack-dev-middleware": "3.0.1",
"webpack-hot-middleware": "2.21.2"
},
"engines": {
Expand All @@ -305,5 +306,6 @@
},
"stylelint": {
"extends": "stylelint-config-standard"
}
},
"sideEffects": false
}
8 changes: 6 additions & 2 deletions webpack/server.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ const app = express();
app.use(webpackDevMiddleware(compiler, serverOptions));
app.use(webpackHotMiddleware(compiler));

app.listen(port, (err) => {
app.listen(port, err => {
if (err) {
debug.error(err);
} else {
debug.info('==> 🚧 Webpack development server listening on port %s', port);
debug.info('==> 💻 Open http://%s:%s in a browser to view the app.', config.host, config.port);
debug.info(
'==> 💻 Open http://%s:%s in a browser to view the app.',
config.host,
config.port,
);
}
});
10 changes: 1 addition & 9 deletions webpack/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const BASE_CSS_LOADER = {
};

module.exports = {
mode: 'development',
devtool: 'inline-source-map',
context: path.resolve(__dirname, '..'),
entry: [
Expand All @@ -101,15 +102,6 @@ module.exports = {
},
],
},
{
test: /\.(json)$/,
exclude: /node_modules/,
use: [
{
loader: 'json-loader',
},
],
},
{
test: /\.less$/,
use: [
Expand Down
43 changes: 13 additions & 30 deletions webpack/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const BASE_CSS_LOADER = {
};

module.exports = {
// SourceMaps in production:
// https://webpack.js.org/configuration/devtool/#production
mode: 'production',
devtool: 'source-map',
context: path.resolve(__dirname, '..'),
entry: {
Expand All @@ -40,15 +39,6 @@ module.exports = {
},
],
},
{
test: /\.(json)$/,
exclude: /node_modules/,
use: [
{
loader: 'json-loader',
},
],
},
{
test: /\.less$/,
use: [
Expand Down Expand Up @@ -154,25 +144,18 @@ module.exports = {
minimize: true,
debug: false,
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false,
},
sourceMap: true,
}),
new webpack.HashedModuleIdsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.[hash].js',
minChunks(module, count) {
const { context } = module;
return context && context.indexOf('node_modules') >= 0;
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
}),
],
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
chunks: 'initial',
test: path.resolve(__dirname, 'node_modules'),
name: 'vendor',
enforce: true,
},
},
},
},
};
Loading

0 comments on commit d1ebf96

Please sign in to comment.