Speed up your Webpack build with lightningcss
pnpm add -D lightningcss-loader
webpack config example:
// webpack.config.js
const { LightningCssMinifyPlugin } = require('lightningcss-loader')
module.exports = {
optimization: {
minimize: true,
minimizer: [
new LightningCssMinifyPlugin()
]
},
};
webpack config example:
// webpack.config.js
// need install `lightningcss`
const LightningCSS = require('lightningcss')
module.exports = {
module: {
rules: [
{
test: /\.scss$/,
use: [
'style-loader', // or MiniCssExtractPlugin.loader
'css-loader',
- 'postcss-loader',
+ {
+ loader: 'lightningcss-loader',
+ options: {
+ implementation: LightningCSS
+ }
+ }
'sass-loader'
],
},
],
},
};
lightningcss can replace autoprefixer
and postcss-preset-env
, if you use custom postcss plugins, you can use both lightningcss-loader
and postcss-loader
.
// webpack.config.js
const { LightningCssMinifyPlugin } = require('lightningcss-loader')
const LightningCSS = require('lightningcss')
module.exports = {
optimization: {
minimizer: [
new LightningCssMinifyPlugin({
implementation: LightningCSS
// ... lightningcss options
})
]
},
};
You can see type tips for detailed configurable items
-
Remove and install:
pnpm remove parcel-css-loader @parcel/css pnpm i -D lightningcss-loader lightningcss
-
Search code and replace to new name:
-
parcel-css-loader
->lightningcss-loader
-
ParcelCssMinifyPlugin
->LightningCssMinifyPlugin
-
MIT