Webpack To Rspack/Cssextractwebpackplugin Community To Included Plugin
Last update
Oct 12, 2024
Handles the migration of the CssExtractWebpackPlugin webpack plug-in into an included plugin in rspack.
Before
// Step 1: Replace the import of 'mini-css-extract-plugin' with '@rspack/core'const CssExtractWebpackPlugin = require('mini-css-extract-plugin');module.exports = {plugins: [// Step 2: Replace 'new CssExtractWebpackPlugin' with 'new rspack.CssExtractRspackPlugin'new CssExtractWebpackPlugin({// ...}),],module: {rules: [{test: /\.css$/i,// Step 3: Replace 'CssExtractWebpackPlugin.loader' with 'rspack.CssExtractRspackPlugin.loader'use: [CssExtractWebpackPlugin.loader, 'css-loader'],// Step 4: Add 'type: "javascript/auto"' to the rule object}, ],},};
After
const rspack = require('@rspack/core');module.exports = {plugins: [new rspack.CssExtractRspackPlugin({// ...}),],module: {rules: [{test: /\.css$/i,use: [rspack.CssExtractRspackPlugin.loader, 'css-loader'],type: 'javascript/auto',}, ],},};
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community