-
-
Notifications
You must be signed in to change notification settings - Fork 188
Unclear how to pass options in postcss.config.js (missing usage in docs) #334
Comments
Is postcss.config.js something official? That said, cssnext is just a normal postcss plugin. I think there is a bug about that. See webpack-contrib/postcss-loader#138 |
@MoOx "scripts": {
"build-css": "postcss --config config/postcss.library.config.js"
} @folmert let config = {
use: [
'postcss-cssnext',
'postcss-import',
'postcss-custom-properties',
'postcss-nesting',
'postcss-calc',
],
'autoprefixer': {
browsers: '> 5%'
},
'postcssCssnext': {
features: {
autoprefixer: true
}
},
// Other options such as input and output
};
module.exports = config; |
@piotr-cz Feel free to make a PR to show the usage of postcss.config.js in the docs! |
@piotr-cz
|
@folmert I was considering postcss-load-config, but after some time got working with postcss-cli |
@MoOx Usage with CLIIt's possible to pass cssnext options in config file as described in postcss-cli docs: {
"input": "screen.css",
"output": "bundle.css",
"postcssCssnext": {
"features": {
"autoprefixer": true
}
}
} |
Webpack2 config for post-css with ExtractTextPlugin:
|
If you prefer store settings in separate js, your config may look like:
|
Without using additional loaders you can pass options in module.exports = {
plugins: {
'postcss-import': {},
'postcss-cssnext': {
features: {
customProperties: { preserve: true }
}
},
'cssnano': { autoprefixer: false }
}
}
The list of all features / plugins names can be found here: https://github.com/MoOx/postcss-cssnext/blob/master/src/features.js Maybe the documentation http://cssnext.io/usage/ can be improved? |
|
Uh oh!
There was an error while loading. Please reload this page.
Instructions posted at http://cssnext.io/usage/ are not very helpful in my case. Sorry, but these docs are very vague, they don't even state in which file should the example be written. These can be obvious things for "insiders", but not for someone new to postcss.
I'm using Webpack 2 and including postcss-cssnext along with other postcss plugins in my postcss.config.js:
and this works, but how do I pass options here?
This syntax doesn't work:
this neither:
When I run webpack I get errors like:
TypeError: Cannot read property 'default' of undefined
or
TypeError: [object Object] must be a function, did you require() it ?
The text was updated successfully, but these errors were encountered: