我有一个gulp任务,当我一次运行任务时有效但由于某种原因我不能得到,当我运行"默认"任务,所有运行都是干净的。我有什么想法吗?下面的脚本。
(function () {
'use strict';
// Load plugins
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
htmlreplace = require('gulp-html-replace');
gulp.task('scripts', function () {
return gulp.src(['public/app/**/*.js','public/app.js'])
.pipe(concat('main.js'))
.pipe(gulp.dest('public/dist'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('public/dist'))
.pipe(notify({message: 'Scripts task complete'}));
});
gulp.task('copyfiles', function () {
gulp.src('public/dist/**/*')
.pipe(gulp.dest('../../ExtJSApps/dash1'))
.pipe(notify({message: 'copyfiles task complete'}));
});
gulp.task('indexhtml', function () {
gulp.src('public/index.html')
.pipe(rename('indexnomin.html'))
.pipe(htmlreplace({
'css': '/ExtJSApps/ext-4.2.2.1144/resources/ext-theme-neptuneext-theme-neptune-all-debug.css',
'js': ['/ExtJSApps/ext-4.2.2.1144/ext-all-dev.js',
'main.js']
}))
.pipe(gulp.dest('public/dist/'))
.pipe(notify({message: 'indexhtml task complete'}));
//console.log('2x');
});
gulp.task('indexhtmlmin', function () {
gulp.src('public/index.html')
.pipe(htmlreplace({
'css': '/ExtJSApps/ext-4.2.2.1144/resources/ext-theme-neptune/ext-theme-neptune-all.css',
'js': [
'/ExtJSApps/ext-4.2.2.1144/ext-all.js',
'main.min.js'
]
}))
.pipe(gulp.dest('public/dist/'))
.pipe(notify({message: 'indexhtmlmin task complete'}));
});
gulp.task('clean', function (cb) {
});
// Default task
gulp.task('default', ['clean'], function () {
gulp.start('scripts','copyfiles', 'indexhtml', 'indexhtmlmin');
});
}());
答案 0 :(得分:1)
最后一行错误的括号:
}());
应该是
})();
此外,您应该知道gulp.start
是deprecated,您应该查看gulp-load-plugins和一般gulp architecture。
答案 1 :(得分:1)
更改
// Default task
gulp.task('default', ['clean'], function () {
gulp.start('scripts','copyfiles', 'indexhtml', 'indexhtmlmin');
});
到
gulp.task('default', ['clean', 'scripts', 'copyfiles', 'indexhtml', 'indexhtmlmin']);