Skip to content

Commit

Permalink
ktl-1711 feat: style bundle optimization (#3905)
Browse files Browse the repository at this point in the history
  • Loading branch information
krutilov authored and berezinant committed Nov 7, 2024
1 parent da945f2 commit 32cac62
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 56 deletions.
94 changes: 42 additions & 52 deletions dokka-subprojects/plugin-base-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dokka-subprojects/plugin-base-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"create-component": "node --experimental-modules create-component.mjs",
"start:ui-kit": "webpack serve --config ./webpack.config-ui-kit.js --env minify=true",
"build:ui-kit:watch": "webpack --config ./webpack.config-ui-kit.js --env watch=true --env minify=true",
"build:ui-kit": "npm run build:ui-kit:minified && npm run build:ui-kit:unminified",
"build:ui-kit": "npm run build:ui-kit:unminified && npm run build:ui-kit:minified",
"build:ui-kit:minified": "webpack --config ./webpack.config-ui-kit.js --env minify=true",
"build:ui-kit:unminified": "webpack --config ./webpack.config-ui-kit.js --env minify=false",
"build": "webpack --mode=production --devtool source-map",
Expand Down
41 changes: 38 additions & 3 deletions dokka-subprojects/plugin-base-frontend/webpack.config-ui-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const WebpackShellPluginNext = require('webpack-shell-plugin-next');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');

module.exports = (env, args) => {
const isMinify = env.minify === 'true';
Expand Down Expand Up @@ -55,9 +56,6 @@ module.exports = (env, args) => {
plugins: [
[
'cssnano',
{
preset: ['default', { discardComments: { removeAll: true } }],
},
],
],
},
Expand All @@ -73,6 +71,21 @@ module.exports = (env, args) => {
},
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
[
'cssnano',
{
preset: ['default', { discardComments: { removeAll: true } }],
},
],
],
},
},
},
'sass-loader',
],
},
Expand All @@ -94,6 +107,28 @@ module.exports = (env, args) => {
},
],
},
optimization: {
minimize: isMinify,
minimizer: [
'...', // Extends existing minimizers
new CssMinimizerPlugin({
minimizerOptions: {
preset: [
'default',
{
discardComments: { removeAll: true },
normalizeWhitespace: isMinify,
plugins: [
[
'cssnano',
],
]
},
],
},
}),
],
},
plugins: [
new MiniCssExtractPlugin({
filename: isMinify ? 'ui-kit.min.css' : 'ui-kit.css',
Expand Down

0 comments on commit 32cac62

Please sign in to comment.