@douyinfe/semi-webpack-plugin 2.60.1 → 2.61.0-alpha.1

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/README.md +0 -169
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-webpack-plugin",
3
- "version": "2.60.1",
3
+ "version": "2.61.0-alpha.1",
4
4
  "description": "",
5
5
  "author": "伍浩威 <wuhaowei.whw@bytedance.com>",
6
6
  "homepage": "",
@@ -38,5 +38,5 @@
38
38
  "rimraf": "^3.0.2",
39
39
  "typescript": "^4"
40
40
  },
41
- "gitHead": "9339ff83a2e2c141f7152b56dd544fe7576d667d"
41
+ "gitHead": "ba06de12d059c24363f1ef151dbf4076ea3969a5"
42
42
  }
package/README.md DELETED
@@ -1,169 +0,0 @@
1
- > A webpack plugin for Semi Design to custom theme、replace prefix and so on.
2
-
3
- ## Introduction
4
- The plugin is designed for Semi Design, support webpack4 and webpack5, provides two major abilities:
5
- - Custom theme
6
- - Replace prefix of CSS selector
7
-
8
- ## Usage
9
-
10
- ### Install
11
- Install `@douyinfe/semi-webpack-plugin` as a development dependency:
12
-
13
- ``` shell
14
- npm install --save-dev @douyinfe/semi-webpack-plugin
15
- # or
16
- yarn add --dev @douyinfe/semi-webpack-plugin
17
- ```
18
-
19
- ### Custom theme
20
- Semi Design uses the Scss variables to extract thousands of Design Tokens. You can replace Token through this plugin to achieve theme customization. [More info](https://semi.design/dsm/)
21
-
22
- You can custom theme through three ways:
23
- - npm package for custom theme
24
- - Local Scss file in your project
25
- - Pass key-value pair parameters to plugin
26
- Priority from low to high.
27
- #### Through npm package
28
-
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
-
31
- ``` js
32
- // webpack.config.js
33
- const SemiPlugin = require('@douyinfe/semi-webpack-plugin').default;
34
-
35
- module.exports = {
36
- // ...
37
- plugins: [
38
- new SemiPlugin({
39
- theme: '@douyinfe/semi-theme-default'
40
- })
41
- ]
42
- // ...
43
- };
44
- ```
45
-
46
- #### Through local Scss file
47
-
48
- You can check which tokens can be customized on the [Semi WebSite](https://semi.design/en-US/basic/tokens).
49
-
50
- - step1: add a local file
51
- ``` scss
52
- // local.scss
53
- $font-size-small: 16px;
54
-
55
- ```
56
- - step2: config webpack
57
- ``` js
58
- // webpack.config.js
59
- const path = require('path');
60
- const SemiPlugin = require('@douyinfe/semi-webpack-plugin').default;
61
-
62
- module.exports = {
63
- // ...
64
- plugins: [
65
- new SemiPlugin({
66
- include: path.join(__dirname, 'local.scss')
67
- })
68
- ]
69
- };
70
- ```
71
-
72
- #### Through parameters
73
- ``` js
74
- // webpack.config.js
75
- const SemiPlugin = require('@douyinfe/semi-webpack-plugin').default;
76
-
77
- module.exports = {
78
- // ...
79
- plugins: [
80
- new SemiPlugin({
81
- variables: {
82
- "$font-size-small": '16px'
83
- }
84
- })
85
- ]
86
- };
87
- ```
88
-
89
- ### Replace prefix of CSS selector
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
-
92
- ``` js
93
- // webpack.config.js
94
- const SemiPlugin = require('@douyinfe/semi-webpack-plugin').default;
95
-
96
- module.exports = {
97
- // ...
98
- plugins: [
99
- new SemiPlugin({
100
- prefixCls: 'custom'
101
- })
102
- ]
103
- // ...
104
- };
105
- ```
106
-
107
- Then you get the replaced CSS selectors(e.g, `.custom-button`).
108
-
109
- ## Api
110
- ### new SemiPlugin(options)
111
-
112
- #### options.prefixCls
113
-
114
- Type: `String`
115
-
116
- The prefix of CSS selector.
117
-
118
- #### options.theme
119
-
120
- Type: `String` or `Object`
121
-
122
- When the type is string, it represents the name of npm for custom theme.You can use [Semi Design System](https://semi.design) to custom theme.
123
-
124
- ##### options.theme.name
125
-
126
- Same performance as when the type of `options.theme` is string.
127
-
128
- ##### options.include
129
-
130
- Type: `String`
131
-
132
- The absolute path of the local Scss file.
133
-
134
- ##### options.variables
135
-
136
- Type: `Object`
137
-
138
- The key-value pair of Scss token.
139
-
140
- ##### options.omitCss
141
-
142
- Type: `Boolean`
143
-
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
-
146
- ##### options.webpackContext.NormalModule
147
-
148
- Type: `webpack NormalModule`
149
-
150
- ##### options.extractCssOptions.loader
151
-
152
- Type: `String`
153
-
154
- The path of webpack loader that extract css.
155
-
156
- ##### options.extractCssOptions.loaderOptions
157
-
158
- Type: `Object`
159
-
160
- The options of webpack loader that extract css.
161
-
162
- #### options.overrideStylesheetLoaders
163
-
164
- Type: `(loaderList:any[])=>any[]`
165
-
166
- You can customize how webpack process semi related styles by override the loader with this option. The function will receive the loader list of default loaders(include options.extractCssOptions) and you should return your new loader list. The best practice is just only add your loader to the list rather than delete or change the default loaders since some core logic is in there.
167
-
168
-
169
- In webpack@5, some hooks need to be obtained through api `NormalModule.getCompilationHooks`. But in some scenarios, webpack will not be installed, such as Next.js. Therefore, the user is required to pass in NormalModule as a parameter.