4

browserify で gulp を使用していますが、brfs-htmlmin を設定するにはどうすればよいですか? npmページで、options.minifyオブジェクトを渡す必要があることがわかりましたが、browserifyを使用してそれを行うにはどうすればよいですか?

これはうまくいきません、ヒントはありますか?(はい、私は新しいです。昨日 node/npm をインストールしました;)

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

最後に brfs-htmlmin ソースを変更しましたが、もっと良い方法があるはずです

brfs-htmlmin ソース:

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
    }; 
4

1 に答える 1

0

に設定を入れるほど便利ではありませんが、に設定をgulpFile.js入れることができます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" }}}]
}
于 2016-10-21T05:34:18.183 に答える