Skip to content

Commit

Permalink
feat(cli): setup css minimiser webpack plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mediremi authored and KaiVandivier committed Aug 23, 2022
1 parent e8ebcbf commit 3f1b1f2
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 90 deletions.
1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"babel-loader": "^8.1.0",
"babel-plugin-react-require": "^3.1.3",
"chokidar": "^3.3.0",
"css-minimizer-webpack-plugin": "^3.4.1",
"detect-port": "^1.3.0",
"dotenv": "^8.1.0",
"dotenv-expand": "^5.1.0",
Expand Down
17 changes: 10 additions & 7 deletions cli/src/lib/plugin/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Based on CRA Webpack config

// TODO: react fast refresh in development

const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent')
Expand Down Expand Up @@ -81,13 +84,12 @@ module.exports = ({ env: webpackEnv, paths }) => {
entry: paths.shellPluginBundleEntrypoint,
output: {
path: paths.shellBuildOutput,
filename: 'plugin.bundle.js',
/*filename: isProduction
? 'static/js/plugin-[name].[contenthash:8].js'
: 'static/js/plugin.bundle.js',*/
/*chunkFilename: isProduction
? 'static/js/plugin-[name].[contenthash:8].chunk.js'
: 'static/js/plugin-[name].chunk.js',*/
filename: isProduction
? 'static/js/plugin-[name].[contenthash:8].js'
: 'static/js/plugin.bundle.js',
chunkFilename: isProduction
? 'static/js/plugin-[name].[contenthash:8].chunk.js'
: 'static/js/plugin-[name].chunk.js',
},
optimization: {
minimize: isProduction,
Expand All @@ -112,6 +114,7 @@ module.exports = ({ env: webpackEnv, paths }) => {
},
},
}),
new CssMinimizerPlugin(),
],
splitChunks: {
chunks: 'all',
Expand Down
Loading

0 comments on commit 3f1b1f2

Please sign in to comment.