首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gulp useref使用npm托管库构建js

gulp useref使用npm托管库构建js
EN

Stack Overflow用户
提问于 2018-03-28 20:00:35
回答 1查看 200关注 0票数 0

我使用的是Yo Generator's web app as base to build something with PUG。然而,它仍然引用Bower。因此,我将所有需要的JS包切换到npm。但是这个gulp任务忽略了node_modules中的所有库

代码语言:javascript
复制
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?

EN

回答 1

Stack Overflow用户

发布于 2018-04-11 19:29:12

事实证明,在某些JS库中,gulp uglify不喜欢像“es6”这样的"let“。因此,解决方案是使用gulp uglify-es。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49533997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档