我上周正在家里做一个新项目,现在我在办公室,我对Gulp没有运气。
当我运行Gulp时没有错误,但它没有创建任何文件,我尝试使用Gulp-tap来查看是否有任何东西被管道但是没有。我确信我在正确的cwd中,文件存在,但我没有运气。该任务也已运行,由console.log 确认。
C:\Users\Jonathan\Documents\GitHub\ITMS-Backend>gulp
[11:02:16] Using gulpfile ~\Documents\GitHub\ITMS-Backend\Gulpfile.js
[11:02:16] Starting 'lint'...
[11:02:16] Starting 'sass'...
[11:02:16] Starting 'global-scripts'...
[11:02:16] Starting 'polymer'...
[11:02:16] Finished 'polymer' after 4.4 ms
[11:02:16] Finished 'lint' after 23 ms
[11:02:16] Finished 'global-scripts' after 14 ms
[11:02:16] Finished 'sass' after 19 ms
[11:02:16] Starting 'default'...
[11:02:16] Finished 'default' after 4.53 µs
截至当前的Gulp文件
var bower_root = 'public/components/'
webcomponents_dir = 'public/webcomponents';
var gulp = require('gulp');
var fs = require('fs');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var vulcanize = require('gulp-vulcanize');
var polymer_modules = [
"core-elements/core-elements.html",
"paper-elements/paper-elements.html"
];
// Lint Task
gulp.task('lint', function() {
return gulp.src('app/assets/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Compile Our Sass
gulp.task('sass', function() {
return gulp.src('app/assets/scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('public/css'));
});
// Concatenate & Minify JS
gulp.task('global-scripts', function() {
return gulp.src('app/assets/js/*.js')
.pipe(concat('global.js'))
.pipe(gulp.dest('public/js'))
.pipe(rename('global.min.js'))
.pipe(uglify())
.pipe(gulp.dest('public/js'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('app/assets/js/*.js', ['lint', 'global-scripts']);
gulp.watch('app/assets/scss/*.scss', ['sass']);
});
gulp.task('polymer', function() {
// Move Polymer JS File
gulp.src("polymer/polymer.min.js", {cwd: bower_root})
.pipe(gulp.dest("public/js/"));
// Move webcomponents file
gulp.src(bower_root + "webcomponentsjs/webcomponents.min.js")
.pipe(gulp.dest("public/js/"));
// CSS Polymer is shipped with
gulp.src("polymer/layout.html", {cwd: bower_root})
.pipe(gulp.dest(webcomponents_dir));
// Vulcanise
gulp.src(polymer_modules, {cwd: bower_root})
.pipe(vulcanize({
dest: './public/webcomponents',
strip: true
}))
.pipe(gulp.dest(webcomponents_dir));
});
// Default Task
gulp.task('default', ['lint', 'sass', 'global-scripts', 'polymer']);