Skip to content

Commit 01bf466

Browse files
authored
feat!: emit CSS files to dist instead of dist/static/css (#460)
1 parent 39ba4d9 commit 01bf466

File tree

11 files changed

+31
-32
lines changed

11 files changed

+31
-32
lines changed

examples/react-component-bundle/rslib.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export default defineConfig({
1010
output: {
1111
distPath: {
1212
root: './dist/esm',
13-
css: '.',
14-
cssAsync: '.',
1513
},
1614
},
1715
},
@@ -21,8 +19,6 @@ export default defineConfig({
2119
output: {
2220
distPath: {
2321
root: './dist/cjs',
24-
css: '.',
25-
cssAsync: '.',
2622
},
2723
},
2824
},

examples/vue-component-bundle/rslib.config.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,7 @@ import { defineConfig } from '@rslib/core';
33

44
export default defineConfig({
55
plugins: [pluginVue()],
6-
lib: [
7-
{
8-
format: 'esm',
9-
output: {
10-
distPath: {
11-
css: '.',
12-
},
13-
},
14-
},
15-
],
6+
lib: [{ format: 'esm' }],
167
output: {
178
target: 'web',
189
},

packages/core/src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ export async function createConstantRsbuildConfig(): Promise<RsbuildConfig> {
463463
filenameHash: false,
464464
distPath: {
465465
js: './',
466+
jsAsync: './',
467+
css: './',
468+
cssAsync: './',
466469
},
467470
},
468471
});

packages/core/tests/__snapshots__/config.test.ts.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
1010
"mode": "production",
1111
"output": {
1212
"distPath": {
13+
"css": "./",
14+
"cssAsync": "./",
1315
"js": "./",
16+
"jsAsync": "./",
1417
},
1518
"externals": [
1619
[Function],
@@ -239,7 +242,10 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
239242
"mode": "production",
240243
"output": {
241244
"distPath": {
245+
"css": "./",
246+
"cssAsync": "./",
242247
"js": "./",
248+
"jsAsync": "./",
243249
},
244250
"externals": [
245251
"assert",
@@ -464,7 +470,10 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
464470
"mode": "production",
465471
"output": {
466472
"distPath": {
473+
"css": "./",
474+
"cssAsync": "./",
467475
"js": "./",
476+
"jsAsync": "./",
468477
},
469478
"externals": [
470479
"assert",

tests/integration/style/css-modules/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ test('should extract css-modules successfully in bundle', async () => {
1010
const esmFiles = Object.keys(contents.esm);
1111
expect(esmFiles).toMatchInlineSnapshot(`
1212
[
13-
"<ROOT>/tests/integration/style/css-modules/bundle/dist/esm/static/css/index.css",
13+
"<ROOT>/tests/integration/style/css-modules/bundle/dist/esm/index.css",
1414
]
1515
`);
1616

1717
const cjsFiles = Object.keys(contents.cjs);
1818
expect(cjsFiles).toMatchInlineSnapshot(`
1919
[
20-
"<ROOT>/tests/integration/style/css-modules/bundle/dist/cjs/static/css/index.css",
20+
"<ROOT>/tests/integration/style/css-modules/bundle/dist/cjs/index.css",
2121
]
2222
`);
2323
});

tests/integration/style/css/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ test('should extract css successfully in bundle', async () => {
1111

1212
expect(files.esm).toMatchInlineSnapshot(`
1313
[
14-
"<ROOT>/tests/integration/style/css/bundle/dist/esm/static/css/index.css",
14+
"<ROOT>/tests/integration/style/css/bundle/dist/esm/index.css",
1515
]
1616
`);
1717

1818
expect(contents.esm).toMatchInlineSnapshot(`
1919
{
20-
"<ROOT>/tests/integration/style/css/bundle/dist/esm/static/css/index.css": "@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css);
20+
"<ROOT>/tests/integration/style/css/bundle/dist/esm/index.css": "@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css);
2121
@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css);
2222
.lib1 {
2323
color: red;
@@ -37,13 +37,13 @@ test('should extract css successfully in bundle', async () => {
3737

3838
expect(files.cjs).toMatchInlineSnapshot(`
3939
[
40-
"<ROOT>/tests/integration/style/css/bundle/dist/cjs/static/css/index.css",
40+
"<ROOT>/tests/integration/style/css/bundle/dist/cjs/index.css",
4141
]
4242
`);
4343

4444
expect(contents.cjs).toMatchInlineSnapshot(`
4545
{
46-
"<ROOT>/tests/integration/style/css/bundle/dist/cjs/static/css/index.css": "@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css);
46+
"<ROOT>/tests/integration/style/css/bundle/dist/cjs/index.css": "@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css);
4747
@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css);
4848
.lib1 {
4949
color: red;

tests/integration/style/less/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ test('should extract css with pluginLess successfully in bundle', async () => {
3333
const esmFiles = Object.keys(contents.esm);
3434
expect(esmFiles).toMatchInlineSnapshot(`
3535
[
36-
"<ROOT>/tests/integration/style/less/bundle/dist/esm/static/css/index.css",
36+
"<ROOT>/tests/integration/style/less/bundle/dist/esm/index.css",
3737
]
3838
`);
3939

4040
const cjsFiles = Object.keys(contents.cjs);
4141
expect(cjsFiles).toMatchInlineSnapshot(`
4242
[
43-
"<ROOT>/tests/integration/style/less/bundle/dist/cjs/static/css/index.css",
43+
"<ROOT>/tests/integration/style/less/bundle/dist/cjs/index.css",
4444
]
4545
`);
4646
});
@@ -52,15 +52,15 @@ test('should extract css with pluginLess successfully in import case', async ()
5252
const esmFiles = Object.keys(contents.esm);
5353
expect(esmFiles).toMatchInlineSnapshot(`
5454
[
55-
"<ROOT>/tests/integration/style/less/bundle-import/dist/esm/static/css/index.css",
55+
"<ROOT>/tests/integration/style/less/bundle-import/dist/esm/index.css",
5656
]
5757
`);
5858
expectFileContainContent(contents.esm, 'index.css', '.lib1 {');
5959

6060
const cjsFiles = Object.keys(contents.cjs);
6161
expect(cjsFiles).toMatchInlineSnapshot(`
6262
[
63-
"<ROOT>/tests/integration/style/less/bundle-import/dist/cjs/static/css/index.css",
63+
"<ROOT>/tests/integration/style/less/bundle-import/dist/cjs/index.css",
6464
]
6565
`);
6666
expectFileContainContent(contents.cjs, 'index.css', '.lib1 {');

tests/integration/style/lightningcss/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test('should extract css with lightningcss-loader successfully in bundle', async
99
const esmFiles = Object.keys(contents.esm);
1010
expect(esmFiles).toMatchInlineSnapshot(`
1111
[
12-
"<ROOT>/tests/integration/style/lightningcss/bundle/dist/esm/static/css/index.css",
12+
"<ROOT>/tests/integration/style/lightningcss/bundle/dist/esm/index.css",
1313
]
1414
`);
1515
expectFileContainContent(
@@ -21,7 +21,7 @@ test('should extract css with lightningcss-loader successfully in bundle', async
2121
const cjsFiles = Object.keys(contents.cjs);
2222
expect(cjsFiles).toMatchInlineSnapshot(`
2323
[
24-
"<ROOT>/tests/integration/style/lightningcss/bundle/dist/cjs/static/css/index.css",
24+
"<ROOT>/tests/integration/style/lightningcss/bundle/dist/cjs/index.css",
2525
]
2626
`);
2727
expectFileContainContent(

tests/integration/style/postcss/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ test('should extract css with postcss-loader successfully in bundle', async () =
1010
const esmFiles = Object.keys(contents.esm);
1111
expect(esmFiles).toMatchInlineSnapshot(`
1212
[
13-
"<ROOT>/tests/integration/style/postcss/bundle/dist/esm/static/css/index.css",
13+
"<ROOT>/tests/integration/style/postcss/bundle/dist/esm/index.css",
1414
]
1515
`);
1616
expectFileContainContent(contents.esm, 'index.css', 'font-size: 16px;');
1717

1818
const cjsFiles = Object.keys(contents.cjs);
1919
expect(cjsFiles).toMatchInlineSnapshot(`
2020
[
21-
"<ROOT>/tests/integration/style/postcss/bundle/dist/cjs/static/css/index.css",
21+
"<ROOT>/tests/integration/style/postcss/bundle/dist/cjs/index.css",
2222
]
2323
`);
2424
expectFileContainContent(contents.cjs, 'index.css', 'font-size: 16px;');

tests/integration/style/sass/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ test('should extract css with pluginSass in bundle', async () => {
88
const esmFiles = Object.keys(contents.esm);
99
expect(esmFiles).toMatchInlineSnapshot(`
1010
[
11-
"<ROOT>/tests/integration/style/sass/bundle/dist/esm/static/css/index.css",
11+
"<ROOT>/tests/integration/style/sass/bundle/dist/esm/index.css",
1212
]
1313
`);
1414

1515
const cjsFiles = Object.keys(contents.cjs);
1616
expect(cjsFiles).toMatchInlineSnapshot(`
1717
[
18-
"<ROOT>/tests/integration/style/sass/bundle/dist/cjs/static/css/index.css",
18+
"<ROOT>/tests/integration/style/sass/bundle/dist/cjs/index.css",
1919
]
2020
`);
2121
});

0 commit comments

Comments
 (0)