|
|
@@ -18,25 +18,43 @@ var htmlminOptions = {
|
|
|
minifyCSS: true //压缩页面CSS
|
|
|
};
|
|
|
|
|
|
-gulp.task('views', function (done) {
|
|
|
+gulp.task('vendor', function (done) {
|
|
|
gulp.src([
|
|
|
- app.srcPath + 'app/**/*.html',
|
|
|
- app.srcPath + 'common/**/*.html'
|
|
|
- ], {allowEmpty: true})
|
|
|
+ 'vendor/angular/angular.js',
|
|
|
+ 'vendor/angular-ui-router/release/angular-ui-router.js',
|
|
|
+ 'vendor/angular-animate/angular-animate.js',
|
|
|
+ 'vendor/angular-cookies/angular-cookies.js',
|
|
|
+ 'vendor/jquery/dist/jquery.js',
|
|
|
+ 'vendor/semantic/dist/semantic.js'
|
|
|
+ ])
|
|
|
.pipe(loader.plumber())
|
|
|
- .pipe(loader.htmlmin(htmlminOptions))
|
|
|
- .pipe(loader.ngHtml2js({prefix: 'app/', moduleName: 'Views'}))
|
|
|
+ .pipe(loader.ngAnnotate({ single_quotes: true }))
|
|
|
+ .pipe(loader.concat('vendor.min.js'))
|
|
|
.pipe(loader.uglify())
|
|
|
- .pipe(loader.concat('views.min.js'))
|
|
|
- .pipe(gulp.dest(app.distPath + 'js'));
|
|
|
+ .pipe(gulp.dest(app.distPath + 'js'))
|
|
|
+ .pipe(loader.connect.reload());
|
|
|
+ gulp.src('vendor/semantic/dist/themes/**/*.*')
|
|
|
+ .pipe(loader.plumber())
|
|
|
+ .pipe(gulp.dest(app.distPath + 'css/themes'))
|
|
|
+ .pipe(loader.connect.reload());
|
|
|
+ gulp.src('vendor/semantic/dist/semantic.min.css')
|
|
|
+ .pipe(loader.plumber())
|
|
|
+ .pipe(gulp.dest(app.distPath + 'css'))
|
|
|
+ .pipe(loader.connect.reload());
|
|
|
done();
|
|
|
});
|
|
|
|
|
|
-gulp.task('index', function (done) {
|
|
|
- gulp.src(app.srcPath + 'index.html')
|
|
|
+gulp.task('views', function (done) {
|
|
|
+ gulp.src([
|
|
|
+ app.srcPath + 'app/**/*.html',
|
|
|
+ app.srcPath + 'common/**/*.html'
|
|
|
+ ], { allowEmpty: true })
|
|
|
.pipe(loader.plumber())
|
|
|
.pipe(loader.htmlmin(htmlminOptions))
|
|
|
- .pipe(gulp.dest(app.distPath))
|
|
|
+ .pipe(loader.ngHtml2js({ prefix: 'app/', moduleName: 'Views' }))
|
|
|
+ .pipe(loader.uglify())
|
|
|
+ .pipe(loader.concat('views.min.js'))
|
|
|
+ .pipe(gulp.dest(app.distPath + 'js'))
|
|
|
.pipe(loader.connect.reload());
|
|
|
done();
|
|
|
});
|
|
|
@@ -57,7 +75,7 @@ gulp.task('less', function (done) {
|
|
|
gulp.task('js', function (done) {
|
|
|
gulp.src(app.srcPath + '**/*.js')
|
|
|
.pipe(loader.plumber())
|
|
|
- .pipe(loader.ngAnnotate({single_quotes: true})) // 自动注入
|
|
|
+ .pipe(loader.ngAnnotate({ single_quotes: true })) // 自动注入
|
|
|
.pipe(loader.concat('app.min.js')) //合并成一个名为index.js文件
|
|
|
.pipe(loader.uglify()) //源自于gulp-uglify,功能压缩js
|
|
|
.pipe(gulp.dest(app.distPath + 'js'))
|
|
|
@@ -73,32 +91,6 @@ gulp.task('images', function (done) {
|
|
|
done();
|
|
|
});
|
|
|
|
|
|
-gulp.task('vendor', function (done) {
|
|
|
- gulp.src([
|
|
|
- 'vendor/angular/angular.js',
|
|
|
- 'vendor/angular-ui-router/release/angular-ui-router.js',
|
|
|
- 'vendor/angular-animate/angular-animate.js',
|
|
|
- 'vendor/angular-cookies/angular-cookies.js',
|
|
|
- 'vendor/jquery/dist/jquery.js',
|
|
|
- 'vendor/semantic/dist/semantic.js'
|
|
|
- ])
|
|
|
- .pipe(loader.plumber())
|
|
|
- .pipe(loader.ngAnnotate({single_quotes: true}))
|
|
|
- .pipe(loader.concat('vendor.min.js'))
|
|
|
- .pipe(loader.uglify())
|
|
|
- .pipe(gulp.dest(app.distPath + 'js'))
|
|
|
- .pipe(loader.connect.reload());
|
|
|
- gulp.src('vendor/semantic/dist/themes/**/*.*')
|
|
|
- .pipe(loader.plumber())
|
|
|
- .pipe(gulp.dest(app.distPath + 'css/themes'))
|
|
|
- .pipe(loader.connect.reload());
|
|
|
- gulp.src('vendor/semantic/dist/semantic.min.css')
|
|
|
- .pipe(loader.plumber())
|
|
|
- .pipe(gulp.dest(app.distPath + 'css'))
|
|
|
- .pipe(loader.connect.reload());
|
|
|
- done();
|
|
|
-});
|
|
|
-
|
|
|
gulp.task('fonts', function (done) {
|
|
|
gulp.src([
|
|
|
app.srcPath + '**/*.woff2',
|
|
|
@@ -113,13 +105,22 @@ gulp.task('fonts', function (done) {
|
|
|
done();
|
|
|
});
|
|
|
|
|
|
+gulp.task('index', function(done) {
|
|
|
+ gulp.src(app.srcPath + 'index.html')
|
|
|
+ .pipe(loader.plumber())
|
|
|
+ .pipe(loader.htmlmin(htmlminOptions))
|
|
|
+ .pipe(gulp.dest(app.distPath))
|
|
|
+ .pipe(loader.connect.reload());
|
|
|
+ done();
|
|
|
+});
|
|
|
+
|
|
|
gulp.task('clean', function (done) {
|
|
|
- gulp.src(app.distPath, {allowEmpty: true}).pipe(loader.clean());
|
|
|
+ gulp.src(app.distPath, { allowEmpty: true }).pipe(loader.clean());
|
|
|
done();
|
|
|
});
|
|
|
|
|
|
// gulp.parallel 并行执行, gulp.series 串行执行
|
|
|
-gulp.task('build', gulp.series('vendor', 'index', 'views', 'less', 'js', 'images', 'fonts'));
|
|
|
+gulp.task('build', gulp.series('vendor', 'views', 'less', 'js', 'images', 'fonts', 'index'));
|
|
|
|
|
|
gulp.task('serve', function () {
|
|
|
//gulp.watch 监听任务,目录下的之资源changed,执行任务流
|