Skip to content

Commit d2d1506

Browse files
authored
content: Update PostCSS examples
- Remove the admonition for Windows users regarding project paths with spaces. The problem (gohugoio/hugo#7333) was resolved in v0.161.0 with commit a54c398b93821865547a9e21c73aad8a1d7f7bc1. - Update the autoprefixer example - Update the purgecss example
1 parent 6c4bd3a commit d2d1506

2 files changed

Lines changed: 14 additions & 21 deletions

File tree

content/en/functions/css/PostCSS.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,16 @@ Step 2
3434
Step 3
3535
: Create a PostCSS configuration file in the root of your project.
3636

37-
```js {file="postcss.config.js"}
38-
module.exports = {
37+
```js {file="postcss.config.mjs" copy=true}
38+
import autoprefixer from 'autoprefixer';
39+
40+
export default {
3941
plugins: [
40-
require('autoprefixer')
42+
autoprefixer
4143
]
4244
};
4345
```
4446

45-
> [!note]
46-
> If you are a Windows user, and the path to your project contains a space, you must place the PostCSS configuration within the package.json file. See [this example] and issue [#7333].
47-
4847
Step 4
4948
: Place your CSS file within the `assets/css` directory.
5049

@@ -107,16 +106,15 @@ To avoid using a PostCSS configuration file, you can specify a minimal configura
107106

108107
The current Hugo environment name (set by `--environment` or in configuration or OS environment) is available in the Node context, which allows constructs like this:
109108

110-
```js
111-
const autoprefixer = require('autoprefixer');
112-
module.exports = {
109+
```js {file="postcss.config.mjs" copy=true}
110+
import autoprefixer from 'autoprefixer';
111+
112+
export default {
113113
plugins: [
114114
process.env.HUGO_ENVIRONMENT !== 'development' ? autoprefixer : null
115115
]
116-
}
116+
};
117117
```
118118

119-
[#7333]: https://github.com/gohugoio/hugo/issues/7333
120119
[Node.js]: https://nodejs.org/en
121120
[PostCSS plugins]: https://postcss.org/docs/postcss-plugins
122-
[this example]: https://github.com/postcss/postcss-load-config#packagejson

content/en/functions/resources/PostProcess.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ Step 3
4444
Step 4
4545
: Create a PostCSS configuration file in the root of your project.
4646

47-
```js {file="postcss.config.js" copy=true}
48-
const autoprefixer = require('autoprefixer');
49-
const purgeCSSPlugin = require('@fullhuman/postcss-purgecss').default;
47+
```js {file="postcss.config.mjs" copy=true}
48+
import autoprefixer from 'autoprefixer';
49+
import purgeCSSPlugin from '@fullhuman/postcss-purgecss';
5050

5151
const purgecss = purgeCSSPlugin({
5252
content: ['./hugo_stats.json'],
@@ -62,17 +62,14 @@ Step 4
6262
safelist: []
6363
});
6464

65-
module.exports = {
65+
export default {
6666
plugins: [
6767
process.env.HUGO_ENVIRONMENT !== 'development' ? purgecss : null,
6868
autoprefixer,
6969
]
7070
};
7171
```
7272

73-
> [!note]
74-
> If you are a Windows user, and the path to your project contains a space, you must place the PostCSS configuration within the package.json file. See [this example] and issue [#7333].
75-
7673
Step 5
7774
: Place your CSS file within the `assets/css` directory.
7875

@@ -136,7 +133,6 @@ You cannot manipulate the values returned from the resource's methods. For examp
136133
{{ $css.RelPermalink | strings.ToUpper }}
137134
```
138135

139-
[#7333]: https://github.com/gohugoio/hugo/issues/7333
140136
[`config/production`]: /configuration/introduction/#configuration-directory
141137
[Autoprefixer]: https://github.com/postcss/autoprefixer
142138
[configure build]: /configuration/build/
@@ -145,4 +141,3 @@ You cannot manipulate the values returned from the resource's methods. For examp
145141
[Node.js]: https://nodejs.org/en
146142
[PostCSS]: https://postcss.org/
147143
[PurgeCSS]: https://github.com/FullHuman/purgecss
148-
[this example]: https://github.com/postcss/postcss-load-config#packagejson

0 commit comments

Comments
 (0)