【发布时间】:2015-02-15 19:11:48
【问题描述】:
我正在使用带有 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
};
【问题讨论】:
-
你在使用 gulp-browserify 插件吗?它已被弃用。使用this and other recipes to use browserify
-
除了@Zasz 的建议之外,还有一些很好的解释说明为什么这里会弃用 gulp-browserify:medium.com/@sogko/gulp-browserify-the-gulp-y-way-bb359b3f9623
标签: javascript node.js gulp browserify brfs