Skip to content

Commit

Permalink
Minify with SWC (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis authored Jun 26, 2024
1 parent 9b1a9e6 commit 2b73e9a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .changeset/nervous-dogs-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'sku': patch
---

Minify build output with [SWC]

Minification of production build output is now performed by [SWC]. Previously this was performed by [Terser]. This should result in a noticeable reduction in build times for larger projects, as well as a slight decrease in bundle size.

[swc]: https://swc.rs/docs/configuration/minification
[terser]: https://terser.org/
12 changes: 11 additions & 1 deletion packages/sku/config/webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,17 @@ const makeWebpackConfig = ({
// The 'TerserPlugin' is actually the default minimizer for webpack
// We add a custom one to ensure licence comments stay inside the final JS assets
// Without this a '*.js.LICENSE.txt' file would be created alongside
minimizer: [new TerserPlugin({ extractComments: false })],
minimizer: [
new TerserPlugin({
extractComments: false,
minify: TerserPlugin.swcMinify,
parallel: true,
terserOptions: {
compress: true,
mangle: true,
},
}),
],
concatenateModules: isProductionBuild,
...(!isLibrary
? {
Expand Down
12 changes: 11 additions & 1 deletion packages/sku/config/webpack/webpack.config.ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,17 @@ const makeWebpackConfig = ({
// The 'TerserPlugin' is actually the default minimizer for webpack
// We add a custom one to ensure licence comments stay inside the final JS assets
// Without this a '*.js.LICENSE.txt' file would be created alongside
minimizer: [new TerserPlugin({ extractComments: false })],
minimizer: [
new TerserPlugin({
extractComments: false,
minify: TerserPlugin.swcMinify,
parallel: true,
terserOptions: {
compress: true,
mangle: true,
},
}),
],
concatenateModules: isProductionBuild,
splitChunks: {
chunks: 'all',
Expand Down
1 change: 1 addition & 0 deletions packages/sku/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@storybook/cli": "^7.0.17",
"@storybook/react": "^7.0.17",
"@storybook/react-webpack5": "^7.0.17",
"@swc/core": "^1.5.25",
"@types/jest": "^29.0.0",
"@types/loadable__component": "^5.13.1",
"@vanilla-extract/jest-transform": "^1.1.0",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 2b73e9a

Please sign in to comment.