【发布时间】:2015-06-03 23:57:56
【问题描述】:
我无法弄清楚为什么我的“grunt watch”命令无法编译。它只是发现已经进行了更改,但实际上并不会将其编译到我的 sass 中。
这是我的 gruntfiles.js
module.exports = function(grunt) {
var devPath = 'dev/';
var distPath = 'dist/';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dev: {
options: {
style: 'nested'
},
files: [{
expand: true,
cwd: devPath + 'scss/',
src: ['*.scss'],
dest: devPath + 'css/',
ext: '.css'
}]
}
},
watch: {
css: {
files: [devPath + '**/*.scss'],
tasks: ['sass:dev']
}
},
emailBuilder: {
test: {
files: [{
expand: true,
cwd: 'dev/',
src: ['*.html'],
dest: 'dist/',
ext: '.html',
}]
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-email-builder');
grunt.registerTask('sass', ['sass']);
grunt.registerTask('dist', ['emailBuilder']);
grunt.registerTask('default', ['watch']);
};
然后这是我在终端中看到的:
运行“监视”任务 等待中...
文件“dev/scss/styles.scss”已更改。
【问题讨论】:
-
如果你测试
grunt sass:dev会发生什么? -
如果您在子文件夹中有
.sass文件,它们将不会继续(除非您@importing 它们)。
标签: javascript sass gruntjs