mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit 'a024bc7d76fcc5e49e8210f9b0896db9ef21861a'
This commit is contained in:
@@ -13,7 +13,7 @@ action:
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.128.0 >}}
|
||||
{{< new-in 0.128.0 />}}
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "css/main.css" | postCSS }}
|
||||
@@ -25,9 +25,13 @@ toc: true
|
||||
|
||||
Follow the steps below to transform CSS using any of the available [PostCSS plugins].
|
||||
|
||||
[postcss plugins]: https://postcss.org/docs/postcss-plugins
|
||||
|
||||
Step 1
|
||||
: Install [Node.js].
|
||||
|
||||
[node.js]: https://nodejs.org/en/download
|
||||
|
||||
Step 2
|
||||
: Install the required Node.js packages in the root of your project. For example, to add vendor prefixes to your CSS rules:
|
||||
|
||||
@@ -36,15 +40,15 @@ npm i -D postcss postcss-cli autoprefixer
|
||||
```
|
||||
|
||||
Step 3
|
||||
: Create a PostCSS configuration file in the root of your project. You must name this file `postcss.config.js` or another [supported file name]. For example:
|
||||
: Create a PostCSS configuration file in the root of your project.
|
||||
|
||||
```js
|
||||
{{< code file=postcss.config.js >}}
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('autoprefixer')
|
||||
]
|
||||
};
|
||||
```
|
||||
{{< /code >}}
|
||||
|
||||
{{% note %}}
|
||||
{{% include "functions/resources/_common/postcss-windows-warning.md" %}}
|
||||
@@ -114,16 +118,9 @@ The current Hugo environment name (set by `--environment` or in configuration or
|
||||
|
||||
```js
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const purgecss = require('@fullhuman/postcss-purgecss');
|
||||
module.exports = {
|
||||
plugins: [
|
||||
autoprefixer,
|
||||
process.env.HUGO_ENVIRONMENT !== 'development' ? purgecss : null
|
||||
process.env.HUGO_ENVIRONMENT !== 'development' ? autoprefixer : null
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[node.js]: https://nodejs.org/en/download
|
||||
[postcss plugins]: https://postcss.org/docs/postcss-plugins
|
||||
[supported file name]: https://github.com/postcss/postcss-load-config#usage
|
||||
[transpile to CSS]: /functions/css/sass/
|
||||
|
Reference in New Issue
Block a user