Closed stevenmccord closed 7 years ago
Hi @stevenmccord, there is no way to use js require() in YAML, JSON or etc. You need to specify your postcss config as JS module file, like:
module.exports = {
// ...
};
This is not an load-grunt-config
issue, but rather a general limitation.
@SolomoN-ua Thanks for the quick reply. I have a similar problem when I go to js as well. I have this:
module.exports = {
postcss: { // please note: in this case this is target name not plugin name (so you can put any keyword, like: foo or dist or production etc.)
options: {
processors: [
require('autoprefixer')({browsers: ['last 2 versions']})
]
},
src: 'app/styles/style.css',
dest: 'app/styles/style-dest.css'
}
};
When I run a grunt postcss --verbose --debug
I get the following:
Running "postcss" task
[D] Task source: /home/ubuntu/stymie-ui/node_modules/grunt-postcss/tasks/postcss.js
Running "postcss:postcss" (postcss) task
[D] Task source: /home/ubuntu/stymie-ui/node_modules/grunt-postcss/tasks/postcss.js
Verifying property postcss.postcss exists in config...OK
Files: app/styles/style.css -> app/styles/style-dest.css
Options: processors=[null], map=false, diff=false, safe=false, failOnError=false, writeDest
Reading app/styles/style.css...OK
Writing app/styles/style-dest.css...OK
File app/styles/style-dest.css created.
>> 1 processed stylesheet created.
If I wrap the processor in quotes I get the is not a PostCSS plugin
error like I did in the YAML probably b/c it is view it as a string.
Below is the grunt --config-debug
for the postcss section:
"postcss": {
"postcss": {
"options": {
"processors": [
null
]
},
"src": "app/styles/style.css",
"dest": "app/styles/style-dest.css"
}
},
Any help you can provide would be great. Thanks!
@stevenmccord is autoprefixer
installed in your project? (npm install autoprefixer
)
@SolomoN-ua yep, confirmed that a few times myself just to make sure :). When I try with the quotes I get that plugin error and if I don't wrap that processor in a quote, it is just null.
@stevenmccord it should not work with quotes in any case because require()
is a js code construction and not a regular string, it should be executed.
@stevenmccord first try to use require('autoprefixer')
without options, if it does not helps try to use it same way as in official documentation https://github.com/postcss/autoprefixer#grunt
It does not look like issue with load-grunt-config
but maybe an issue with grunt-postcss
plugins itself.
P.S.: maybe connected with this issue https://github.com/nDmitry/grunt-postcss/issues/107
@SolomoN-ua I have been running it and it looks like it actually is processing it, just the debug information is saying it is null. So it looks like it is working just not outputting what I thought it would be. Thanks for all your help, sorry to bother you with a non-issue!
@stevenmccord no problem, glad to hear that everything work fine. Have a nice day! :)
I am been doing some research, but I can't seem to figure out why I am getting thrown an error that a plugin can't be loaded.
Here is the
grunt postcss --verbose --debug
Here is the
grunt --config debug
Here is the YAML config:
I have tried it with files and option for the src and dest, just no luck. If anyone has any ideas that would be extremely helpful. Thanks!