Skip to content

Commit

Permalink
feat: support stylus in bundleless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 committed Jan 26, 2025
1 parent d213f43 commit 297dacb
Show file tree
Hide file tree
Showing 12 changed files with 314 additions and 16 deletions.
9 changes: 8 additions & 1 deletion packages/core/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ const JS_EXTENSIONS: string[] = [
'ctsx',
] as const;

const CSS_EXTENSIONS: string[] = ['css', 'sass', 'scss', 'less'] as const;
const CSS_EXTENSIONS: string[] = [
'css',
'sass',
'scss',
'less',
'styl',
'stylus',
] as const;

export const JS_EXTENSIONS_PATTERN: RegExp = new RegExp(
`\\.(${JS_EXTENSIONS.join('|')})$`,
Expand Down
105 changes: 91 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tests/integration/style/sass/bundle/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ export default defineConfig({
],
output: {
target: 'web',
assetPrefix: 'auto', // TODO: move this line to packages/core/src/asset/assetConfig.ts
},
});
4 changes: 4 additions & 0 deletions tests/integration/style/stylus/__fixtures__/src/a.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body
color red
font 14px Arial, sans-serif
background: url('./assets/logo.svg');
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions tests/integration/style/stylus/__fixtures__/src/b.module.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.title-class
font-size: 14px;
4 changes: 4 additions & 0 deletions tests/integration/style/stylus/__fixtures__/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import './a.styl';
import style from './b.module.styl';

console.log(style);
9 changes: 9 additions & 0 deletions tests/integration/style/stylus/bundle-false/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "style-stylus-bundle-false-test",
"version": "1.0.0",
"private": true,
"type": "module",
"devDependencies": {
"@rsbuild/plugin-stylus": "^1.0.7"
}
}
23 changes: 23 additions & 0 deletions tests/integration/style/stylus/bundle-false/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { pluginStylus } from '@rsbuild/plugin-stylus';
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from 'test-helper';

export default defineConfig({
lib: [
generateBundleEsmConfig({
bundle: false,
}),
generateBundleCjsConfig({
bundle: false,
}),
],
source: {
entry: {
index: ['../__fixtures__/src/**'],
},
},
plugins: [pluginStylus()],
output: {
target: 'web',
},
});
9 changes: 9 additions & 0 deletions tests/integration/style/stylus/bundle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "style-stylus-bundle-test",
"version": "1.0.0",
"private": true,
"type": "module",
"devDependencies": {
"@rsbuild/plugin-stylus": "^1.0.7"
}
}
16 changes: 16 additions & 0 deletions tests/integration/style/stylus/bundle/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { pluginStylus } from '@rsbuild/plugin-stylus';
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from 'test-helper';

export default defineConfig({
lib: [generateBundleEsmConfig(), generateBundleCjsConfig()],
source: {
entry: {
index: ['../__fixtures__/src/index.js'],
},
},
plugins: [pluginStylus()],
output: {
target: 'web',
},
});
Loading

0 comments on commit 297dacb

Please sign in to comment.