Gulp 如何将Bower提供的javascript添加到Google';s Web初学者工具包
我已经安装了一些Bower软件包,并希望将它们包括在Gulp构建过程中。我尝试将它们添加到Gulp 如何将Bower提供的javascript添加到Google';s Web初学者工具包,gulp,bower,google-web-starter-kit,Gulp,Bower,Google Web Starter Kit,我已经安装了一些Bower软件包,并希望将它们包括在Gulp构建过程中。我尝试将它们添加到script部分的gulpfile.babel.js: gulp.task('scripts', () => gulp.src([ // Note: Since we are not using useref in the scripts build pipeline, // you need to explicitly list your scripts
script
部分的gulpfile.babel.js
:
gulp.task('scripts', () =>
gulp.src([
// Note: Since we are not using useref in the scripts build pipeline,
// you need to explicitly list your scripts here in the right order
// to be correctly concatenated
'./bower_components/jquery/dist/jquery.js',
'./bower_components/bootstrap-sass/assets/javascripts/bootstrap.js',
'./app/scripts/main.js'
// Other scripts
])
.pipe($.newer('.tmp/scripts'))
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.sourcemaps.write())
.pipe(gulp.dest('.tmp/scripts'))
.pipe($.concat('main.min.js'))
.pipe($.uglify({preserveComments: 'some'}))
// Output files
.pipe($.size({title: 'scripts'}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist/scripts'))
);
但这将在/dist/scripts目录中构建一个单独的小型化main.min.js
如何将脚本导入到构建管道中,使其包含在app/scripts/main.js中
当然,要做到像向项目中添加Bower提供的JS这样简单的事情不会这么困难。关于什么是最佳实践,我在文档中找不到任何内容