简体   繁体   中英

gulp + browserify transform configuration

I'm using gulp with browserify, how can I configure brfs-htmlmin? on npm page i find out I should pass options.minify object but how can I do that using browserify?

This doesn't work, any hints? (yes i'm new I installed node/npm yesterday;)

gulp.task('scripts', ['clean'], function () {
    gulp.src('Components/initialize.js')
        .pipe(browserify({
            transform: ['brfs-htmlmin', { "opts": {minify: {removeComments: false}} }]
        }))
        .pipe(gulp.dest('./buildjs'));
});

In the end i modified brfs-htmlmin source but there must be better way

brfs-htmlmin source:

module.exports = function(file, opts) {
    if(/\.json$/.test(file)) return through();

    opts = opts || {};
    opts.minify = opts.minify || {
        removeComments: false,
        collapseWhitespace: true,
        collapseBooleanAttributes: true,
        removeAttributeQuotes: true,
        removeRedundantAttributes: true,
        removeEmptyAttributes: true
    }; 

Though not as convenient as putting the configuration on gulpFile.js you can put the configuration on package.json .

"//": "browserify transform config doesn't work if placed on gulpFile.js or karma.conf.js",
"browserify": {
    "debug": "true",
    "transform": ["brfs-htmlmin", { "opts": { "minify": {"removeComments": "false" }}}]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM