Skip to content

Commit a9c4e9d

Browse files
committed
Add instructions for CSS-in-JS & Parcel
1 parent 6f23795 commit a9c4e9d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

docs/README-cn.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,55 @@ PostCSS 可以转化样式到任意语法,不仅仅是 CSS。
164164

165165
[选择插件]: http://postcss.parts
166166

167+
### CSS-in-JS
168+
169+
同时使用 PostCSS 与 CSS-in-JS 的最好方式是 [`astroturf`](https://github.com/4Catalyzer/astroturf),将它的 loader 添加到 `webpack.config.js` 中:
170+
171+
```js
172+
module.exports = {
173+
module: {
174+
rules: [
175+
{
176+
test: /\.css$/,
177+
use: ['style-loader', 'postcss-loader'],
178+
},
179+
{
180+
test: /\.jsx?$/,
181+
use: ['babel-loader', 'astroturf/loader'],
182+
}
183+
]
184+
}
185+
}
186+
```
187+
188+
然后创建 `postcss.config.js`
189+
190+
```js
191+
module.exports = {
192+
plugins: [
193+
require('autoprefixer'),
194+
require('postcss-nested')
195+
]
196+
}
197+
```
198+
199+
### Parcel
200+
201+
[Parcel](https://parceljs.org/) 有内建的 PostCSS 支持,并已经使用 Autoprefixer 和 cssnano。如果你想更换插件,请在项目根目录中创建 `postcss.config.js`
202+
203+
```js
204+
module.exports = {
205+
plugins: [
206+
require('autoprefixer'),
207+
require('postcss-nested')
208+
]
209+
}
210+
```
211+
212+
Parcel 甚至会自动地帮你安装这些插件。
213+
214+
> 请注意[第 1 版中存在的几个问题](https://github.com/parcel-bundler/parcel/labels/CSS%20Preprocessing),第 2 版通过 [issue #2157](https://github.com/parcel-bundler/parcel/projects/5) 解决了这些问题。
215+
167216
### Webpack
168217

169218
`webpack.config.js` 里使用 [`postcss-loader`] :

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy