You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable TypeScript for your `tailwind.config.js`? Sure, why not?
62
+
希望在你的 `tailwind.config.js` 启用 TypeScript?当然可以。
63
63
64
-
Rename it to `tailwind.config.ts`and things just work!
64
+
将它重命名为 `tailwind.config.ts`即可。
65
65
66
66
```ts
67
67
// tailwind.config.ts
@@ -84,33 +84,33 @@ export default defineConfig({
84
84
})
85
85
```
86
86
87
-
### Pug Support
87
+
### Pug Support {#pug-support}
88
88
89
-
It will automatically enable Pug support for `.pug`and Vue SFC when dependency `pug` is found in the workspace.
89
+
当在工作区中找到依赖项 `pug` 时,它将自动启用对 `.pug`和 Vue SFC 的支持。
90
90
91
-
### "Design in DevTools"
91
+
### "DevTools 设计" {#design-in-devtools}
92
92
93
-
It might be a common practice when you use the purge-based Tailwind where you have all the classes in your browser and you can try how things work by directly changing the classes in DevTools. While you might think this is some kind of limitation of "on-demand" where the DevTools don't know those you haven't used in your source code yet.
It will be enabled automatically for you, have fun!
103
+
它将自动帮你启用。
104
104
105
-
Oh, and don't worry about the final bundle, in production build `virtual:windi-devtools`will be an empty module and you don't have to do anything about it :)
> ⚠️ Please use it with caution, under the hood we use [MutationObserver](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)to detect the class changes. Which means not only your manual changes but also the changes made by your scripts will be detected and included in the stylesheet. This could cause some misalignment between dev and the production build when **using dynamically constructed classes** (false-positive). We recommended adding your dynamic parts to the `safelist`or setup UI regression tests for your production build if possible.
By default, we scan your source code statically and find all the usages of the utilities then generated corresponding CSS on-demand. However, there is some limitation that utilities that decided in the runtime can not be matched efficiently, for example
For that, you will need to specify the possible combinations in the `safelist` options of `vite.config.js`.
133
+
因此,你需要在 `vite.config.js` 的 `safelist` 选项中指定可能的组合
134
134
135
135
```ts
136
136
// windi.config.ts
@@ -141,7 +141,7 @@ export default defineConfig({
141
141
})
142
142
```
143
143
144
-
Or you can do it this way
144
+
或者,也可以这样做
145
145
146
146
```ts
147
147
// windi.config.ts
@@ -153,16 +153,15 @@ function range(size, startAt = 1) {
153
153
154
154
exportdefaultdefineConfig({
155
155
safelist: [
156
-
range(30).map(i=>`p-${i}`), // p-1 to p-3
157
-
range(10).map(i=>`mt-${i}`), // mt-1 to mt-10
156
+
range(30).map(i=>`p-${i}`), //从 p-1 到 p-3
157
+
range(10).map(i=>`mt-${i}`), //从 mt-1 到 mt-10
158
158
],
159
159
})
160
160
```
161
161
162
-
### Scanning
162
+
### 扫描 {#scanning}
163
163
164
-
On server start, `vite-plugin-windicss` will scan your source code and extract the utility usages. By default,
165
-
only files under `src/` with extensions `vue, html, mdx, pug, jsx, tsx` will be included. If you want to enable scanning for other file types of locations, you can configure it via:
By default, importing `virtual:windi.css`will import all the three layers with the order `base - components - utilities`. If you want to have better controls over the orders, you can separate them by:
@@ -273,7 +272,7 @@ By default, importing `virtual:windi.css` will import all the three layers with
273
272
+ import 'virtual:windi-utilities.css'
274
273
```
275
274
276
-
You can also make your custom css been able to be overridden by certain layers:
275
+
你还可以使自定义的 css 能够被某些层覆盖:
277
276
278
277
```diff
279
278
import 'virtual:windi-base.css'
@@ -282,27 +281,27 @@ You can also make your custom css been able to be overridden by certain layers:
282
281
import 'virtual:windi-utilities.css'
283
282
```
284
283
285
-
### More
284
+
### 更多 {#more}
286
285
287
-
See[options.ts](https://github.com/windicss/vite-plugin-windicss/blob/main/packages/plugin-utils/src/options.ts)for more configuration reference.
See [examples](https://github.com/windicss/vite-plugin-windicss/blob/main/examples)for*react*, *vue*and*vue with pug*sample projects, or[`Vitesse`](https://github.com/antfu/vitesse)
298
+
请参阅 [示例](https://github.com/windicss/vite-plugin-windicss/blob/main/examples)中的*react* 、*vue*和*vue with pug*示例项目,或[`Vitesse`](https://github.com/antfu/vitesse)
0 commit comments