@douyinfe/semi-rspack-plugin 0.0.1 → 2.25.0-alpha.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 +83 -0
- package/README.md +17 -20
- package/lib/componentName.d.ts +2 -0
- package/lib/componentName.js +63 -0
- package/lib/loaders/semi-theme-loader.js +21 -1
- package/lib/rule.js +6 -1
- package/package.json +5 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 DouyinFE
|
|
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.
|
|
22
|
+
|
|
23
|
+
The code implementation of the external library is referenced by DouyinFe are:
|
|
24
|
+
|
|
25
|
+
- animate.css
|
|
26
|
+
|
|
27
|
+
The MIT License (MIT)
|
|
28
|
+
|
|
29
|
+
Copyright (c) 2020 Daniel Eden
|
|
30
|
+
|
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
32
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
33
|
+
in the Software without restriction, including without limitation the rights
|
|
34
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
35
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
36
|
+
furnished to do so, subject to the following conditions:
|
|
37
|
+
|
|
38
|
+
The above copyright notice and this permission notice shall be included in all
|
|
39
|
+
copies or substantial portions of the Software.
|
|
40
|
+
|
|
41
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
42
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
43
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
44
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
45
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
46
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
47
|
+
SOFTWARE.
|
|
48
|
+
|
|
49
|
+
- Ant Design
|
|
50
|
+
MIT LICENSE
|
|
51
|
+
|
|
52
|
+
Copyright (c) 2015-present Ant UED, https://xtech.antfin.com/
|
|
53
|
+
|
|
54
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
55
|
+
a copy of this software and associated documentation files (the
|
|
56
|
+
"Software"), to deal in the Software without restriction, including
|
|
57
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
58
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
59
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
60
|
+
the following conditions:
|
|
61
|
+
|
|
62
|
+
The above copyright notice and this permission notice shall be
|
|
63
|
+
included in all copies or substantial portions of the Software.
|
|
64
|
+
|
|
65
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
66
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
67
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
68
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
69
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
70
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
71
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
72
|
+
|
|
73
|
+
- rc-tree
|
|
74
|
+
|
|
75
|
+
MIT LICENSE
|
|
76
|
+
|
|
77
|
+
Copyright (c) 2015-present Alipay.com, https://www.alipay.com/
|
|
78
|
+
|
|
79
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
80
|
+
|
|
81
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
82
|
+
|
|
83
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
> A
|
|
1
|
+
> A rspack plugin for Semi Design to custom theme、replace prefix and so on.
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
|
-
The plugin is designed for Semi Design, support
|
|
4
|
+
The plugin is designed for Semi Design, support rspack, provides two major abilities:
|
|
5
5
|
- Custom theme
|
|
6
6
|
- Replace prefix of CSS selector
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
9
|
|
|
10
10
|
### Install
|
|
11
|
-
Install `@douyinfe/semi-
|
|
11
|
+
Install `@douyinfe/semi-rspack-plugin` as a development dependency:
|
|
12
12
|
|
|
13
13
|
``` shell
|
|
14
|
-
npm install --save-dev @douyinfe/semi-
|
|
14
|
+
npm install --save-dev @douyinfe/semi-rspack-plugin
|
|
15
15
|
# or
|
|
16
|
-
yarn add --dev @douyinfe/semi-
|
|
16
|
+
yarn add --dev @douyinfe/semi-rspack-plugin
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
### Custom theme
|
|
@@ -29,8 +29,8 @@ Priority from low to high.
|
|
|
29
29
|
In order to use the npm package, you need to customize the theme through [Semi Design System](https://semi.design/dsm/).After finishing the customization, Semi DSM will generate a npm package for you, and then you can use it like this.
|
|
30
30
|
|
|
31
31
|
``` js
|
|
32
|
-
//
|
|
33
|
-
const SemiPlugin = require('@douyinfe/semi-
|
|
32
|
+
// rspack.config.js
|
|
33
|
+
const SemiPlugin = require('@douyinfe/semi-rspack-plugin').default;
|
|
34
34
|
|
|
35
35
|
module.exports = {
|
|
36
36
|
// ...
|
|
@@ -45,7 +45,7 @@ module.exports = {
|
|
|
45
45
|
|
|
46
46
|
#### Through local Scss file
|
|
47
47
|
|
|
48
|
-
You can check which tokens can be customized on the [Semi WebSite](https://semi.design/
|
|
48
|
+
You can check which tokens can be customized on the [Semi WebSite](https://semi.design/en-US/basic/tokens).
|
|
49
49
|
|
|
50
50
|
- step1: add a local file
|
|
51
51
|
``` scss
|
|
@@ -53,11 +53,11 @@ You can check which tokens can be customized on the [Semi WebSite](https://semi.
|
|
|
53
53
|
$font-size-small: 16px;
|
|
54
54
|
|
|
55
55
|
```
|
|
56
|
-
- step2: config
|
|
56
|
+
- step2: config rspack
|
|
57
57
|
``` js
|
|
58
|
-
//
|
|
58
|
+
// rspack.config.js
|
|
59
59
|
const path = require('path');
|
|
60
|
-
const SemiPlugin = require('@douyinfe/semi-
|
|
60
|
+
const SemiPlugin = require('@douyinfe/semi-rspack-plugin').default;
|
|
61
61
|
|
|
62
62
|
module.exports = {
|
|
63
63
|
// ...
|
|
@@ -71,8 +71,8 @@ module.exports = {
|
|
|
71
71
|
|
|
72
72
|
#### Through parameters
|
|
73
73
|
``` js
|
|
74
|
-
//
|
|
75
|
-
const SemiPlugin = require('@douyinfe/semi-
|
|
74
|
+
// rspack.config.js
|
|
75
|
+
const SemiPlugin = require('@douyinfe/semi-rspack-plugin').default;
|
|
76
76
|
|
|
77
77
|
module.exports = {
|
|
78
78
|
// ...
|
|
@@ -90,8 +90,8 @@ module.exports = {
|
|
|
90
90
|
The CSS selectors used by Semi Design is prefixed with semi by default(e.g, `.semi-button`).You can replace the prefix through this plugin.
|
|
91
91
|
|
|
92
92
|
``` js
|
|
93
|
-
//
|
|
94
|
-
const SemiPlugin = require('@douyinfe/semi-
|
|
93
|
+
// rspack.config.js
|
|
94
|
+
const SemiPlugin = require('@douyinfe/semi-rspack-plugin').default;
|
|
95
95
|
|
|
96
96
|
module.exports = {
|
|
97
97
|
// ...
|
|
@@ -143,21 +143,18 @@ Type: `Boolean`
|
|
|
143
143
|
|
|
144
144
|
In the compilation phase, whether to exclude css references.Used to solve the problem that Next.js does not support the global introduction of css in third-party code.See this [discussion](https://github.com/vercel/next.js/discussions/27953).
|
|
145
145
|
|
|
146
|
-
##### options.webpackContext.NormalModule
|
|
147
|
-
|
|
148
|
-
Type: `webpack NormalModule`
|
|
149
146
|
|
|
150
147
|
##### options.extractCssOptions.loader
|
|
151
148
|
|
|
152
149
|
Type: `String`
|
|
153
150
|
|
|
154
|
-
The path of webpack loader that extract css.
|
|
151
|
+
The path of webpack/rspack loader that extract css.
|
|
155
152
|
|
|
156
153
|
##### options.extractCssOptions.loaderOptions
|
|
157
154
|
|
|
158
155
|
Type: `Object`
|
|
159
156
|
|
|
160
|
-
The options of webpack loader that extract css.
|
|
157
|
+
The options of webpack/rspack loader that extract css.
|
|
161
158
|
|
|
162
159
|
#### options.overrideStylesheetLoaders
|
|
163
160
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const componentVariablePathList = [
|
|
4
|
+
'@douyinfe/semi-foundation/navigation/variables.scss',
|
|
5
|
+
'@douyinfe/semi-foundation/avatar/variables.scss',
|
|
6
|
+
'@douyinfe/semi-foundation/pagination/variables.scss',
|
|
7
|
+
'@douyinfe/semi-foundation/grid/variables.scss',
|
|
8
|
+
'@douyinfe/semi-foundation/tabs/variables.scss',
|
|
9
|
+
'@douyinfe/semi-foundation/highlight/variables.scss',
|
|
10
|
+
'@douyinfe/semi-foundation/image/variables.scss',
|
|
11
|
+
'@douyinfe/semi-foundation/banner/variables.scss',
|
|
12
|
+
'@douyinfe/semi-foundation/space/variables.scss',
|
|
13
|
+
'@douyinfe/semi-foundation/autoComplete/variables.scss',
|
|
14
|
+
'@douyinfe/semi-foundation/rating/variables.scss',
|
|
15
|
+
'@douyinfe/semi-foundation/notification/variables.scss',
|
|
16
|
+
'@douyinfe/semi-foundation/spin/variables.scss',
|
|
17
|
+
'@douyinfe/semi-foundation/tooltip/variables.scss',
|
|
18
|
+
'@douyinfe/semi-foundation/calendar/variables.scss',
|
|
19
|
+
'@douyinfe/semi-foundation/dropdown/variables.scss',
|
|
20
|
+
'@douyinfe/semi-foundation/transfer/variables.scss',
|
|
21
|
+
'@douyinfe/semi-foundation/collapse/variables.scss',
|
|
22
|
+
'@douyinfe/semi-foundation/timePicker/variables.scss',
|
|
23
|
+
'@douyinfe/semi-foundation/tag/variables.scss',
|
|
24
|
+
'@douyinfe/semi-foundation/upload/variables.scss',
|
|
25
|
+
'@douyinfe/semi-foundation/tree/variables.scss',
|
|
26
|
+
'@douyinfe/semi-foundation/descriptions/variables.scss',
|
|
27
|
+
'@douyinfe/semi-foundation/carousel/variables.scss',
|
|
28
|
+
'@douyinfe/semi-foundation/datePicker/variables.scss',
|
|
29
|
+
'@douyinfe/semi-foundation/table/variables.scss',
|
|
30
|
+
'@douyinfe/semi-foundation/breadcrumb/variables.scss',
|
|
31
|
+
'@douyinfe/semi-foundation/modal/variables.scss',
|
|
32
|
+
'@douyinfe/semi-foundation/popover/variables.scss',
|
|
33
|
+
'@douyinfe/semi-foundation/collapsible/variables.scss',
|
|
34
|
+
'@douyinfe/semi-foundation/inputNumber/variables.scss',
|
|
35
|
+
'@douyinfe/semi-foundation/card/variables.scss',
|
|
36
|
+
'@douyinfe/semi-foundation/slider/variables.scss',
|
|
37
|
+
'@douyinfe/semi-foundation/treeSelect/variables.scss',
|
|
38
|
+
'@douyinfe/semi-foundation/sideSheet/variables.scss',
|
|
39
|
+
'@douyinfe/semi-foundation/radio/variables.scss',
|
|
40
|
+
'@douyinfe/semi-foundation/progress/variables.scss',
|
|
41
|
+
'@douyinfe/semi-foundation/checkbox/variables.scss',
|
|
42
|
+
'@douyinfe/semi-foundation/anchor/variables.scss',
|
|
43
|
+
'@douyinfe/semi-foundation/steps/variables.scss',
|
|
44
|
+
'@douyinfe/semi-foundation/tagInput/variables.scss',
|
|
45
|
+
'@douyinfe/semi-foundation/typography/variables.scss',
|
|
46
|
+
'@douyinfe/semi-foundation/button/variables.scss',
|
|
47
|
+
'@douyinfe/semi-foundation/skeleton/variables.scss',
|
|
48
|
+
'@douyinfe/semi-foundation/list/variables.scss',
|
|
49
|
+
'@douyinfe/semi-foundation/popconfirm/variables.scss',
|
|
50
|
+
'@douyinfe/semi-foundation/toast/variables.scss',
|
|
51
|
+
'@douyinfe/semi-foundation/timeline/variables.scss',
|
|
52
|
+
'@douyinfe/semi-foundation/input/variables.scss',
|
|
53
|
+
'@douyinfe/semi-foundation/divider/variables.scss',
|
|
54
|
+
'@douyinfe/semi-foundation/form/variables.scss',
|
|
55
|
+
'@douyinfe/semi-foundation/scrollList/variables.scss',
|
|
56
|
+
'@douyinfe/semi-foundation/backtop/variables.scss',
|
|
57
|
+
'@douyinfe/semi-foundation/cascader/variables.scss',
|
|
58
|
+
'@douyinfe/semi-foundation/select/variables.scss',
|
|
59
|
+
'@douyinfe/semi-foundation/badge/variables.scss',
|
|
60
|
+
'@douyinfe/semi-foundation/switch/variables.scss',
|
|
61
|
+
'@douyinfe/semi-foundation/empty/variables.scss',
|
|
62
|
+
];
|
|
63
|
+
exports.default = componentVariablePathList;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const enhanced_resolve_1 = __importDefault(require("enhanced-resolve"));
|
|
7
|
+
const componentName_1 = __importDefault(require("../componentName"));
|
|
7
8
|
function SemiThemeLoader(source) {
|
|
8
9
|
const query = this.getOptions();
|
|
9
10
|
const theme = query.name || '@douyinfe/semi-theme-default';
|
|
@@ -50,7 +51,26 @@ function SemiThemeLoader(source) {
|
|
|
50
51
|
const prefixCls = query.prefixCls || 'semi';
|
|
51
52
|
const prefixClsStr = `$prefix: '${prefixCls}';\n`;
|
|
52
53
|
if (shouldInject) {
|
|
53
|
-
|
|
54
|
+
const customStr = (() => {
|
|
55
|
+
let customStr = '';
|
|
56
|
+
try {
|
|
57
|
+
const collectAllVariablesPath = [
|
|
58
|
+
...componentName_1.default,
|
|
59
|
+
];
|
|
60
|
+
if (componentVariables) {
|
|
61
|
+
collectAllVariablesPath.push(`${theme}/scss/local.scss`);
|
|
62
|
+
}
|
|
63
|
+
collectAllVariablesPath.push(`${theme}/scss/custom.scss`);
|
|
64
|
+
customStr = collectAllVariablesPath.map(p => {
|
|
65
|
+
return `@import "~${p}";`;
|
|
66
|
+
}).join('\n') + '\n' + customStr;
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
customStr = ''; // fallback to empty string
|
|
70
|
+
}
|
|
71
|
+
return `body:not(:not(body)){${customStr}};`;
|
|
72
|
+
})();
|
|
73
|
+
return `${animationStr}${cssVarStr}${scssVarStr}${prefixClsStr}${fileStr}${customStr}`;
|
|
54
74
|
}
|
|
55
75
|
else {
|
|
56
76
|
return `${scssVarStr}${prefixClsStr}${fileStr}`;
|
package/lib/rule.js
CHANGED
|
@@ -18,7 +18,12 @@ function createThemeLoaderRule(opts) {
|
|
|
18
18
|
else {
|
|
19
19
|
themeOptions.name = opts.theme;
|
|
20
20
|
}
|
|
21
|
-
const options =
|
|
21
|
+
const options = {
|
|
22
|
+
...themeOptions,
|
|
23
|
+
prefixCls: opts.prefixCls,
|
|
24
|
+
variables: (0, utils_1.stringifyVariableRecord)(opts.variables),
|
|
25
|
+
include: opts.include,
|
|
26
|
+
};
|
|
22
27
|
return {
|
|
23
28
|
test: /@douyinfe\/semi-(ui|icons|foundation)\/lib\/.+\.scss$/,
|
|
24
29
|
use: [{ loader: constants_1.THEME_LOADER, options }],
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-rspack-plugin",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "2.25.0-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"author": "伍浩威 <wuhaowei.whw@bytedance.com>",
|
|
6
5
|
"homepage": "",
|
|
7
6
|
"license": "MIT",
|
|
8
7
|
"main": "lib/index.js",
|
|
@@ -15,7 +14,8 @@
|
|
|
15
14
|
],
|
|
16
15
|
"scripts": {
|
|
17
16
|
"build:lib": "rimraf lib && tsc",
|
|
18
|
-
"dev": "tsc -w --sourceMap"
|
|
17
|
+
"dev": "tsc -w --sourceMap",
|
|
18
|
+
"prepublishOnly": "npm run build:lib"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/core": "^7.15.4",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"typescript": "^4",
|
|
31
31
|
"webpack": "^5.77.0"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
-
}
|
|
33
|
+
"gitHead": "a2d9b9c6d2bf2464f8bccdbfa56e2e07429013cf"
|
|
34
|
+
}
|