所以我有一个gulp配置,它将我所有的angular文件连接成一个文件。
下面是相关的部分
const jsPaths = [
'src/js/**/*.js', // no more than 100 files
'node_modules/angular-google-places-autocomplete/src/autocomplete.js',
'node_modules/angular-foundation-6/dist/angular-foundation.js',
'node_modules/angular-slugify/angular-slugify.js',
'node_modules/satellizer/satellizer.js',
'node_modules/angular-toastr/dist/angular-toastr.tpls.js',
'node_modules/angular-filter/dist/angular-filter.js'
]
gulp.task('jsbundle', function(done){
jsbundle(done)
})
gulp.task('js', ['jsbundle'], function(){
transpileJs()
})
function jsbundle(done){
gulp.src(jsPaths)
.pipe(concat('concat.js'))
.pipe(gulp.dest('tmp'))
.on('end', function() {
done();
});
}Finished 'jsbundle' after 5.04 s
完成的文件大小约为1.5mb
我能做些什么来加快速度吗?
发布于 2017-05-13 15:51:52
你可以很容易地用uglify来缩小它。首先安装uglify和rename:
npm install -rename gulp-uglify --save-dev 并添加:
`function jsbundle(done){
gulp.src(jsPaths)
.pipe(concat('concat.js'))
.pipe(gulp.dest('tmp'))
.pipe(rename('concat.min.js'))
.pipe(uglify())
.pipe(gulp.dest('tmp'));
.on('end', function() {
done();
});
}`https://stackoverflow.com/questions/38531272
复制相似问题