Skip to content

Commit

Permalink
Optimize build speed (#948)
Browse files Browse the repository at this point in the history
* Fix incorrect webpack mode argument.

* User terser webpack plugin as build minimizer.

* Use HardSourceWebpackPlugin for webpack caching.
  • Loading branch information
Hyperkid123 authored Sep 3, 2020
1 parent dd212b1 commit 6d60bd4
Show file tree
Hide file tree
Showing 4 changed files with 487 additions and 34 deletions.
4 changes: 2 additions & 2 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const plugins = require('./webpack.plugins.js');
const TerserPlugin = require('terser-webpack-plugin');

const commonConfig = ({
publicPath,
Expand All @@ -25,8 +26,7 @@ const commonConfig = ({
}
},
optimization: {
minimize: true,
concatenateModules: false
minimizer: [new TerserPlugin({ sourceMap: true })]
},
module: {
rules: [
Expand Down
2 changes: 2 additions & 0 deletions config/webpack.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ const webpack = require('webpack');
const LodashWebpackPlugin = require('lodash-webpack-plugin');
const WriteFileWebpackPlugin = require('write-file-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');

const plugins = [
new CleanWebpackPlugin(),
new HardSourceWebpackPlugin(),
new WriteFileWebpackPlugin(),
new webpack.SourceMapDevToolPlugin({
test: /\.js/i,
Expand Down
Loading

0 comments on commit 6d60bd4

Please sign in to comment.