我有一个grunt文件,但我在编译时遇到问题。当我观看它似乎运行正常但不产生任何文件。
我错过了什么?
module.exports = function(grunt) {
grunt.initConfig({
pngmin: {
compile: {
options: {
ext: '.png',
force: true,
speed: 3,
colors: 200
},
files: [{
expand: true, // required option
src: ['**/*.png'],
cwd: 'public/images/src/', // required option
dest: 'public/images/dist/'
}]
}
},
sass: {
dist: {
files: [
{
expand: true,
cwd: "public/sass",
src: ["**/*.sass"],
dest: "public/stylesheets",
ext: ".css"
}
]
}
},
watch: {
css: {
files: '**/*.scss',
tasks: ['sass']
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-pngmin');
grunt.registerTask('default', ['pngmin', 'watch', 'sass']);
};
答案 0 :(得分:3)
您正在观看 scss 文件,但 sass 任务中有 sass 文件。
假设您使用的是 sass 文件,则必须将代码更改为以下内容:
sass: {
dist: {
files: [
{
expand: true,
cwd: "public/sass",
src: ["**/*.sass"],
dest: "public/stylesheets",
ext: ".css"
}
]
}
},
watch: {
css: {
files: '**/*.sass',
tasks: ['sass']
}
}
问候。