2017-10-16 50 views
0

當我的文件結構是這樣的,在同一個文件夾gulp watch正在工作並註冊變更咕嘟咕嘟不能註冊修改時的舉動SCSS文件到文件夾中

├─ styles 
    ├── _color.scss 
    ├── _mixins.scss 
    ├── _layout.scss 
    ├── _navigation.scss 
    ├── main.scss 

main.scss

@import "colors"; 
@import "mixins"; 
@import "navigation"; 

但是,當我移動SCSS文件夾成這樣:

enter image description here

並導入它從主文件:

@import "globals/colors"; 
@import "globals/mixins"; 
@import "components/navigation"; 

它不工作,而不是註冊運行一飲而盡手錶時的任何變化。這裏是我的gulpfile.js:

var gulp = require('gulp'), 
 
\t \t sass = require ('gulp-sass'), 
 
\t \t notify = require('gulp-notify'), 
 
\t \t mainBowerFiles = require('main-bower-files'), 
 
\t \t filter = require('gulp-filter'), 
 
\t \t autoprefixer = require('gulp-autoprefixer'), 
 
\t \t concat = require('gulp-concat'), 
 
\t \t uglify = require('gulp-uglify'); 
 

 
var config = { 
 
\t stylesPath: 'assets/styles', 
 
\t jsPath: 'assets/scripts', 
 
\t bowerDir: 'bower_components'
 , 
 
\t outputDir: 'public' 
 
} 
 

 
gulp.task('js', function() { 
 
\t return gulp.src(mainBowerFiles().concat(config.jsPath+'/*')) 
 
\t \t .pipe(filter('**/*.js')) 
 
\t \t .pipe(concat('main.js')) 
 
\t \t .pipe(uglify()) 
 
\t \t .pipe(gulp.dest(config.outputDir + '/js')); 
 
}); 
 

 
gulp.task('icons', function() {
 
 
\t return gulp.src(config.bowerDir + '/font-awesome/fonts/**.*')
 
 
\t \t .pipe(gulp.dest(config.outputDir + '/fonts'));
 
 
}); 
 

 
gulp.task('css', function() { 
 
\t return gulp.src(config.stylesPath + '/main.scss') 
 
\t \t .pipe(sass({ 
 
\t \t \t \t outputStyle: 'compressed', 
 
\t \t \t \t includePaths: [ 
 
\t \t \t \t \t config.stylesPath, 
 
\t \t \t \t \t config.bowerDir + '/bootstrap-sass/assets/stylesheets', 
 
\t \t \t \t \t config.bowerDir + '/font-awesome/scss' 
 
\t \t \t \t ] 
 
\t \t \t }).on('error', sass.logError)) 
 
\t \t .pipe(autoprefixer()) 
 
\t \t .pipe(gulp.dest(config.outputDir + '/css')); 
 
}); 
 

 
gulp.task('watch', function(){ 
 
\t gulp.watch([config.stylesPath + '**/*.scss', config.stylesPath + '**/*.sass', config.stylesPath + '**/*.css'], ['css']); 
 

 
\t gulp.watch([config.jsPath + '**/*.js'], ['js']); 
 

 
}) 
 

 
gulp.task('default', ['js', 'css', 'icons']);

那麼,什麼是我的項目結構的問題,使gulp watch不工作?

+0

您可以在scss文件名中嘗試使用它嗎? – Rahi

+1

不應該'config.stylesPath +'**/*。scss''爲'config.stylesPath +'/ **/*。scss''? – peinearydevelopment

回答

0

這是我的gulp.js文件,任務監視的問題。我將其更改爲:

gulp.task('watch', function(){ 
    gulp.watch([config.stylesPath + '/**/*.scss', config.stylesPath + '/**/*.sass', config.stylesPath + '/**/*.css'], ['css']); 

    gulp.watch([config.jsPath + '**/*.js'], ['js']); 

})