@rsbuild/plugin-tailwindcss 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +24 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @rsbuild/plugin-tailwindcss
|
|
2
|
+
|
|
3
|
+
An Rsbuild plugin to use Tailwind CSS.
|
|
4
|
+
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://npmjs.com/package/@rsbuild/plugin-tailwindcss">
|
|
7
|
+
<img src="https://img.shields.io/npm/v/@rsbuild/plugin-tailwindcss?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
|
|
8
|
+
</a>
|
|
9
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
|
|
10
|
+
<a href="https://npmcharts.com/compare/@rsbuild/plugin-tailwindcss"><img src="https://img.shields.io/npm/dm/@rsbuild/plugin-tailwindcss.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
|
+
See [Documentation](https://rsbuild.rs/plugins/list/plugin-tailwindcss).
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
[MIT](https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
export declare const PLUGIN_TAILWINDCSS_NAME = "rsbuild:tailwindcss";
|
|
3
|
+
export type PluginTailwindcssOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Enable Tailwind CSS's built-in Lightning CSS optimization.
|
|
6
|
+
*
|
|
7
|
+
* This overlaps with Rsbuild's built-in Lightning CSS optimization. It is
|
|
8
|
+
* recommended to enable this option only when Rsbuild's built-in Lightning
|
|
9
|
+
* CSS optimization is disabled.
|
|
10
|
+
*
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
optimize?: boolean | {
|
|
14
|
+
/**
|
|
15
|
+
* Enable minification in Tailwind CSS's built-in Lightning CSS optimization.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
minify?: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const pluginTailwindcss: (options?: PluginTailwindcssOptions) => RsbuildPlugin;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
let src_require = createRequire(import.meta.url), PLUGIN_TAILWINDCSS_NAME = 'rsbuild:tailwindcss', pluginTailwindcss = (options = {})=>({
|
|
3
|
+
name: PLUGIN_TAILWINDCSS_NAME,
|
|
4
|
+
setup (api) {
|
|
5
|
+
api.modifyBundlerChain((chain, { CHAIN_ID, environment, target })=>{
|
|
6
|
+
if (!chain.module.rules.has(CHAIN_ID.RULE.CSS)) return;
|
|
7
|
+
let { output } = environment.config, tailwindOptions = {
|
|
8
|
+
base: api.context.rootPath,
|
|
9
|
+
optimize: options.optimize ?? !1
|
|
10
|
+
}, emitCss = output.emitCss ?? 'web' === target, addTailwindLoader = (rule)=>{
|
|
11
|
+
((rule, cssUseId)=>{
|
|
12
|
+
if (!rule.uses.has(cssUseId)) return;
|
|
13
|
+
let cssLoader = rule.uses.get(cssUseId), options = cssLoader.get('options');
|
|
14
|
+
null === options || 'object' != typeof options || Array.isArray(options) || cssLoader.options({
|
|
15
|
+
...options,
|
|
16
|
+
importLoaders: 'number' == typeof options.importLoaders ? options.importLoaders + 1 : 1
|
|
17
|
+
});
|
|
18
|
+
})(rule, CHAIN_ID.USE.CSS), rule.use('tailwindcss').loader(src_require.resolve('@tailwindcss/webpack')).options(tailwindOptions);
|
|
19
|
+
}, cssRule = chain.module.rule(CHAIN_ID.RULE.CSS);
|
|
20
|
+
addTailwindLoader(cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_URL)), emitCss && addTailwindLoader(cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_MAIN)), addTailwindLoader(cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_INLINE));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
export { PLUGIN_TAILWINDCSS_NAME, pluginTailwindcss };
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rsbuild/plugin-tailwindcss",
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
|
+
"description": "Tailwind CSS plugin for Rsbuild",
|
|
5
|
+
"homepage": "https://rsbuild.rs",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/web-infra-dev/rsbuild",
|
|
9
|
+
"directory": "packages/plugin-tailwindcss"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@tailwindcss/webpack": "^4.3.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@rslib/core": "0.21.5",
|
|
28
|
+
"@types/node": "^24.12.4",
|
|
29
|
+
"typescript": "^6.0.3",
|
|
30
|
+
"@rsbuild/core": "2.0.7",
|
|
31
|
+
"@scripts/test-helper": "1.0.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@rsbuild/core": "^2.0.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependenciesMeta": {
|
|
37
|
+
"@rsbuild/core": {
|
|
38
|
+
"optional": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"registry": "https://registry.npmjs.org/"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "rslib",
|
|
47
|
+
"dev": "rslib -w"
|
|
48
|
+
}
|
|
49
|
+
}
|