New to Grunt, trying to get a Gruntfile running for a wordpress project. I’ve got a package.json and Gruntfile.js in my root directory. I want to add grunt-postcss, but when I followed the instructions, I keep getting “Warning: Task “grunt-postcss” not found.” I’ve probably set up Grunt wrong, as no matter what I run, I get task not found. Here’s my Gruntfile contents:
module.exports = function(grunt) {
grunt.initConfig({
postcss: {
options: {
map: true, // inline sourcemaps
processors: [
require('pixrem')(), // add fallbacks for rem units
require('autoprefixer')({browsers: 'last 2 versions'}), // add vendor prefixes
require('cssnano')() // minify the result
]
},
dist: {
src: 'css/*.css'
}
}
});
grunt.loadNpmTasks('grunt-postcss');
grunt.registerTask('default', ['grunt-postcss']);
};
Make sure you have installed the grunt-postcss module.
npm install grunt-postcss –save-dev
I think you should change
to
Make sure that you have postcss installed.
npm install grunt-postcss
Execute the following command in your shell(make sure to be inside virtualenv if you are using one):
export PATH="/PATH_TO_YOUR_NODE_MODULES_DIRECTORY/.bin:$PATH"
What the above command does is, it update your PATH variable and tells it to also check the above directory while looking for a command.