这是我的 gruntfile.js,它与 sass/style.scss 和 package.json 位于同一目录中。 package.json
安装了 grunt
、grunt-contrib-sass
和 grunt-cli
。
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// this is where you set up your Sass settings. Once you know what you're doing, you can change thse.
Sass: {
dist: {
options: {
style: 'compressed'
},
files: {
'style.css': 'sass/style.scss'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.registerTask('default', ["Sass"]);
};
知道为什么我收到任务未找到错误吗?
最佳答案
将 Saas
更改为 saas
,如 example 中所示配置。
注意:任务名称的正确拼写以小写字母 (s
) 开头。
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: { // <-- Change to lowercase `s`
dist: {
options: {
style: 'compressed'
},
files: {
'style.css': 'sass/style.scss'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.registerTask('default', ["sass"]); // <-- Change to lowercase `s`
};
关于javascript - 未找到 Grunt 任务 (grunt-contrib-sass),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46759015/