Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Bundle optimizations with PurgeCSS and Terser (#959)
Browse files Browse the repository at this point in the history
Bundle optimizations with PurgeCSS and Terser
  • Loading branch information
Ben Junya committed Jun 3, 2019
2 parents 08f6b1f + 3bd286f commit 998482d
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 271 deletions.
4 changes: 3 additions & 1 deletion web/init/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@
"eslint": "^5.5.0",
"eslint-loader": "^2.1.0",
"file-loader": "^2.0.0",
"glob": "^7.1.4",
"jest": "^23.6.0",
"jest-enzyme": "^6.0.4",
"jsdoc-babel": "^0.5.0",
"mini-css-extract-plugin": "^0.4.3",
"node-sass": "^4.9.3",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"postcss-loader": "^3.0.0",
"postcss-scss": "^2.0.0",
"publish": "^0.6.0",
"purgecss-webpack-plugin": "^1.5.0",
"react": "^16.5.1",
"react-dom": "^16.5.1",
"react-markdown-gen": "^0.0.11",
Expand All @@ -88,6 +89,7 @@
"source-map-support": "^0.5.9",
"style-loader": "^0.23.0",
"svg-url-loader": "^2.3.2",
"terser-webpack-plugin": "^1.3.0",
"uglifyjs-webpack-plugin": "^2.1.3",
"url-loader": "^1.1.1",
"webpack": "^4.20.2",
Expand Down
21 changes: 13 additions & 8 deletions web/init/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
const path = require("path");
const glob = require('glob');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const DashboardPlugin = require("webpack-dashboard/plugin");
const TerserPlugin = require('terser-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const PurgecssPlugin = require('purgecss-webpack-plugin');

const basePlugins = [
new MiniCssExtractPlugin({
filename: "styles.css"
}),
new PurgecssPlugin({
paths: glob.sync(`${path.join(__dirname, "src")}/**/*`, { nodir: true })
})
];

module.exports = (env, { mode }) => {
Expand All @@ -33,17 +38,17 @@ module.exports = (env, { mode }) => {
optimizations = {
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: false,
uglifyOptions: {
new TerserPlugin({
terserOptions: {
warnings: false,
parallel: true,
sourceMap: false,
output: {
comments: false
}
}
}),
new OptimizeCSSAssetsPlugin()
})
]
}
}
Expand Down
Loading

0 comments on commit 998482d

Please sign in to comment.