Reputation: 1651
I am using gulp-modernizr and I have read how to set destination folder, file name and many options (everything explained in the documentation)
But I don't know how to set configuration file, I have tried setting the src but it doesn't work:
gulp.task('modernizr', function() {
gulp.src("./node_modules/modernizr/lib/config-all.json")
.pipe(modernizr('outputFileName.js'))
.pipe(gulp.dest('node_modules/modernizr/')) // destination folder
});
I know how to do it from command line:
modernizr -c ./lib/config-all.json
But could anybody explain how to set the configuration file location using gulp-modernizr?
Upvotes: 0
Views: 1080
Reputation: 30564
You don't pass the location of your config file to gulp-modernizr
. Instead you pass the settings themselves as an object:
gulp.task('modernizr', function() {
var settings = {
"options" : [
"setClasses",
"addTest",
"html5printshiv",
"testProp",
"fnBind"
]
};
return gulp.src('./js/*.js')
.pipe(modernizr('outputFileName.js', settings))
.pipe(gulp.dest('node_modules/modernizr/')) // destination folder
});
If you have a JSON config file that you want to use you can read that file using require()
and pass the resulting object to modernizr()
:
gulp.task('modernizr', function() {
var settings = require('./node_modules/modernizr/lib/config-all.json');
return gulp.src('./js/*.js')
.pipe(modernizr('outputFileName.js', settings))
.pipe(gulp.dest('node_modules/modernizr/')) // destination folder
});
Upvotes: 4