Gulp を使用してスタイラスをコンパイルしていますが、タスクが 2 回実行されているようgulp-notify
です。
ここに私のgulpfile.jsがあります
var gulp, plugins;
gulp = require('gulp');
plugins = require('gulp-load-plugins')();
/**
* Watch for changes on stylus files, when detecting change run stylus task
* @return {void}
*/
gulp.task('watch-stylus', function() {
gulp.src('./app/Resources/stylus/**/*.styl')
.pipe(plugins.plumber())
.pipe(plugins.watch('./app/Resources/stylus/**/*.styl', {
verbose: true,
readDelay: 0
}))
.pipe(plugins.exec('gulp stylus'))
.pipe(plugins.notify("Stylus compiled"))
.pipe(plugins.plumber.stop());
});
/**
* Compile stylus and auto prefix the compiled css
* @return {void}
*/
gulp.task('stylus', function() {
gulp.src(['./app/Resources/stylus/**/*.styl', '!./app/Resources/stylus/**/_*.styl'])
.pipe(plugins.plumber())
.pipe(plugins.stylus())
.pipe(plugins.autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(plugins.plumber.stop())
.pipe(gulp.dest('web/css'));
});
確認したこと
- 複数の宛先はありません。
- 入力ディレクトリと出力ディレクトリが異なります。
私が使用しているプラグイン
gulp-load-plugins
プラグインをロードするにはgulp-watch
ファイルの変更を監視するgulp-notify
スタイラスがコンパイルされたことを通知するgulp-stylus
スタイラスをコンパイルするgulp-exec
パーシャルが編集された場合でもコンパイルタスクを実行するgulp-autoprefixer
css にプレフィックスを付けるgulp-plumber
エラーで死ぬことgulp-watch
はありません