我使用的是Yo Generator's web app as base to build something with PUG。然而,它仍然引用Bower。因此,我将所有需要的JS包切换到npm。但是这个gulp任务忽略了node_modules中的所有库
gulp.task('html', ['views', 'styles', 'scripts'], () => {
return gulp.src([
'tmp/**/*.html',
'app/**/*.html',
'!app/layouts/**/*'
])
.pipe($.useref({searchPath: [paths.tmp, paths.src, '.']}))
.pipe($.if(/\.js$/, $.uglify({ compress: {drop_console: true} })))
.pipe($.if(/\.css$/, $.cssnano({ safe: true, autoprefixer: true })))
.pipe($.if(/\.html$/, $.htmlmin({
collapseWhitespace: true,
minifyCSS: true,
minifyJS: {compress: {drop_console: true}},
processConditionalComments: true,
removeComments: true,
removeEmptyAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
})))
.pipe(gulp.dest('dist'));
});有没有办法告诉gulp-useref从路径/node_modules/中组合js lib?
发布于 2018-04-11 19:29:12
事实证明,在某些JS库中,gulp uglify不喜欢像“es6”这样的"let“。因此,解决方案是使用gulp uglify-es。
https://stackoverflow.com/questions/49533997
复制相似问题