I am trying to use less-plugin-clean-css with grunt-contrib-less but I am unable to get it to run. It seems the grunt configuration can't find or install the plugin. This is for a fork of bootstrap that I maintain.
I have updated the Gruntfile.js with:
grunt.initConfig({
...
less: {
compileCore: {
options: {
strictMath: true,
sourceMap: true,
outputSourceFiles: true,
+ plugins: [
+ (new require('less-plugin-clean-css')({
+ "advanced": true,
+ "compatibility": "ie8"
+ }))
+ ],
sourceMapURL: '<%= pkg.name %>.css.map',
sourceMapFilename: 'dist/css/<%= pkg.name %>.css.map'
},
src: 'less/bootstrap.less',
dest: 'dist/css/<%= pkg.name %>.css'
...
}
},
Installed the plugin:
npm install less-plugin-clean-css --save-dev
Run grunt
and get this error:
Running "less:compileCore" (less) task
>> TypeError: Cannot read property 'install' of undefined
What am I missing?
The correct syntax needs additional parentheses around require: