grunt watch 并且 sass 没有编译。它只是注意到变化
grunt watch and sass is not compiling. It just notices change
我不明白为什么我的 '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']);
};
然后这是我在终端中看到的:
运行"watch"任务
等待...
File "dev/scss/styles.scss" changed.
您的 sass 任务中存在无限循环,只需删除以下行:
grunt.registerTask('sass', ['sass']);
我认为您需要更改 sass
配置文件
files: [{
expand: true,
cwd: devPath,
src: ['scss/**/*.scss'],
dest: devPath + 'css/',
ext: '.css'
}]
我不明白为什么我的 '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']);
};
然后这是我在终端中看到的:
运行"watch"任务 等待...
File "dev/scss/styles.scss" changed.
您的 sass 任务中存在无限循环,只需删除以下行:
grunt.registerTask('sass', ['sass']);
我认为您需要更改 sass
配置文件
files: [{
expand: true,
cwd: devPath,
src: ['scss/**/*.scss'],
dest: devPath + 'css/',
ext: '.css'
}]