Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
374 changes: 234 additions & 140 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions rspack/css-chunking-plugin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
15 changes: 15 additions & 0 deletions rspack/css-chunking-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "example-css-chunking-plugin",
"version": "1.0.0",
"private": true,
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "rspack build",
"dev": "rspack serve"
},
"devDependencies": {
"@rspack/cli": "1.4.0-rc.0",
"@rspack/core": "1.4.0-rc.0"
}
}
27 changes: 27 additions & 0 deletions rspack/css-chunking-plugin/rspack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { rspack } = require('@rspack/core');

/** @type {import('@rspack/cli').Configuration} */
const config = {
entry: './src/index.js',
plugins: [
new rspack.HtmlRspackPlugin({
template: './index.html',
}),
// Without using CssChunkingPlugin, the current splitChunks configuration will split CSS modules into multiple chunks, causing CSS style errors
new rspack.experiments.CssChunkingPlugin({
// options
}),
],
experiments: {
css: true,
},
optimization: {
minimize: false,
splitChunks: {
maxSize: 100,
minSize: 0,
}
}
};

module.exports = config;
1 change: 1 addition & 0 deletions rspack/css-chunking-plugin/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import("./page");
11 changes: 11 additions & 0 deletions rspack/css-chunking-plugin/src/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "./styles/global.css";
import "./styles/theme.css";
import "./styles/component.css";

document.addEventListener
const button = document.createElement('button');
button.className = 'btn';
button.style.width = '200px';
button.style.height = '50px';
button.textContent = 'background should be black';
document.body.appendChild(button);
3 changes: 3 additions & 0 deletions rspack/css-chunking-plugin/src/styles/component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.btn {
background-color: black;
}
4 changes: 4 additions & 0 deletions rspack/css-chunking-plugin/src/styles/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.btn {
background-color: red;
color: white;
}
3 changes: 3 additions & 0 deletions rspack/css-chunking-plugin/src/styles/theme.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.btn {
background-color: blue;
}