第一次运行Grunt和Sass,我在修改scss文件时在终端中收到此错误:
danales-MacBook-Pro:sass-test danale$ grunt
Running "watch" task
Waiting...
>> File "SCSS/_main.scss" changed.
Running "sass:dev" (sass) task
Warning: Path must be a string. Received undefined Use --force to continue.
Aborted due to warnings.
Completed in 0.587s at Thu Apr 20 2017 12:47:54 GMT-0400 (EDT) - Waiting...
>> File "SCSS/_mixins.scss" changed.
Running "sass:dev" (sass) task
Warning: Path must be a string. Received undefined Use --force to continue.
Aborted due to warnings.
Completed in 0.545s at Thu Apr 20 2017 12:49:12 GMT-0400 (EDT) - Waiting...
根据我的理解,错误是说我的gruntfile中的路径需要是一个字符串:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/**
* SASS
*/
sass: {
dev: {
options: {
style: 'expanded',
sourcemap: 'none',
},
files: {
'style.css': 'scss/style.css'
}
}
},
/**
* watch
*/
watch: {
css: {
files: '**/*.scss',
tasks: ['sass']
}
},
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default',['watch']);
}
但我不清楚哪条路需要成为一个字符串......
答案 0 :(得分:0)
它说的是你指向的sass文件不在那里。从watch
输出我可以看到该目录实际上被称为SCSS/
(与scss/
相对)。此外,您还没有指出要预处理的 scss 文件。尝试更改sass
任务配置以指示正确的目录和主scss文件:
files: {
'style.css': 'SCSS/_main.scss' // update this match your PRIMARY scss file
}