Skip to content

Commit a72a04b

Browse files
committed
feat(core): support Rspack builtin CSS
1 parent dc3e081 commit a72a04b

17 files changed

Lines changed: 852 additions & 72 deletions

File tree

e2e/cases/css/enable-experiments-css/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getFileContent } from '@rstackjs/test-utils';
33

44
const COMPILE_WARNING = 'Compile Warning';
55

6-
test('should allow to enable Rspack experiments.css', async ({ build }) => {
6+
test('should allow to enable experiments.css', async ({ build }) => {
77
const rsbuild = await build();
88
const files = rsbuild.getDistFiles();
99
const content = getFileContent(files, 'index.css');
@@ -13,7 +13,7 @@ test('should allow to enable Rspack experiments.css', async ({ build }) => {
1313
rsbuild.expectNoLog(COMPILE_WARNING);
1414
});
1515

16-
test('should allow to enable Rspack experiments.css with style-loader', async ({ build }) => {
16+
test('should allow to enable experiments.css with style injection', async ({ build }) => {
1717
const rsbuild = await build({
1818
config: {
1919
output: {

e2e/cases/css/enable-experiments-css/rsbuild.config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { defineConfig } from '@rsbuild/core';
22

33
export default defineConfig({
4-
tools: {
5-
rspack: {
6-
experiments: {
7-
css: true,
8-
},
9-
},
4+
experiments: {
5+
css: true,
106
},
117
output: {
128
filenameHash: false,

packages/core/src/configChain.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const CHAIN_ID = {
7272
JS_TEXT: 'js-text',
7373
/** CSS oneOf rules */
7474
CSS_MAIN: 'css',
75+
CSS_MODULE: 'css-module',
7576
CSS_RAW: 'css-raw',
7677
CSS_TEXT: 'css-text',
7778
CSS_URL: 'css-url',

packages/core/src/defaultConfig.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ const getDefaultResolveConfig = (): NormalizedResolveConfig => {
214214

215215
const createDefaultConfig = (): RsbuildConfig => ({
216216
dev: getDefaultDevConfig(),
217+
experiments: {
218+
css: false,
219+
},
217220
server: getDefaultServerConfig(),
218221
html: getDefaultHtmlConfig(),
219222
resolve: getDefaultResolveConfig(),

packages/core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export type {
7676
DistPathConfig,
7777
EnvironmentConfig,
7878
EnvironmentContext,
79+
ExperimentsConfig,
7980
FilenameConfig,
8081
FilenameHash,
8182
HistoryApiFallbackContext,
@@ -121,6 +122,7 @@ export type {
121122
NormalizedConfig,
122123
NormalizedDevConfig,
123124
NormalizedEnvironmentConfig,
125+
NormalizedExperimentsConfig,
124126
NormalizedHtmlConfig,
125127
NormalizedModuleFederationConfig,
126128
NormalizedOutputConfig,

0 commit comments

Comments
 (0)