You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vargulp=require('gulp');varcoffee=require('gulp-coffee');varconcat=require('gulp-concat');varuglify=require('gulp-uglify');varimagemin=require('gulp-imagemin');varsourcemaps=require('gulp-sourcemaps');vardel=require('del');varpaths={scripts: ['client/js/**/*.coffee','!client/external/**/*.coffee'],images: 'client/img/**/*'};// Not all tasks need to use streams// A gulpfile is just another node program and you can use any package available on npmgulp.task('clean',function(){// You can use multiple globbing patterns as you would with `gulp.src`returndel(['build']);});gulp.task('scripts',['clean'],function(){// Minify and copy all JavaScript (except vendor scripts)// with sourcemaps all the way downreturngulp.src(paths.scripts).pipe(sourcemaps.init()).pipe(coffee()).pipe(uglify()).pipe(concat('all.min.js')).pipe(sourcemaps.write()).pipe(gulp.dest('build/js'));});// Copy all static imagesgulp.task('images',['clean'],function(){returngulp.src(paths.images)// Pass in options to the task.pipe(imagemin({optimizationLevel: 5})).pipe(gulp.dest('build/img'));});// Rerun the task when a file changesgulp.task('watch',function(){gulp.watch(paths.scripts,['scripts']);gulp.watch(paths.images,['images']);});// The default task (called when you run `gulp` from cli)gulp.task('default',['watch','scripts','images']);
The text was updated successfully, but these errors were encountered:
写于 2016-10-11
安装nodejs
初始化项目
npm init
安装gulp
安装依赖包
npm install
创建gulp配置文件
gulpfile.js
执行gulp任务
gulp [taskname]
官方范例
gulpfile.js
The text was updated successfully, but these errors were encountered: