我的操作系统是Ubuntu 14.04
我正在安装Nodejs,Ruby,NPM和sass版本:Sass 3.4.9(选择性Steve)
我正在终端中运行“ grunt sass”任务!此任务正在运行并显示此消息:
$ grunt sass
Running "sass:files" (sass) task
Done, without errors.
但不创建CSS文件
config grunt文件在这里:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
watch: {
jsProject: {
files: [
'<%= jshint.project.src %>'
],
tasks: ['jshint:project']
},
cssBootstrap: {
files: [
'sass/bootstrap/*.scss'
],
tasks: [
"sass:bootstrap"
]
},
sassProject: {
files: [
'sass/project/*.scss'
],
tasks: [
"sass"
]
},
cssProject: {
files: [
'css/project/*.css'
],
tasks: [
"csslint"
]
}
},
jshint: {
project: {
src: ["js/project/*.js"],
options: {
jshintrc: "grunt/.jshintrc"
}
}
},
csslint: {
options: {
csslintrc: 'grunt/.csslintrc'
},
src: {
bootstrap: "sass/_bootstrap.scss",
project: "sass/project/include.scss",
projectCss: "css/project/include.css"
}
},
cssmin: {
production: {
options: {
paths: ["sass"],
cleancss: true,
compress: true,
ieCompat: true,
strictImports : true,
syncImport : true
},
files: {
'css/style.min.css': '<%= csslint.src.project %>',
'css/template.min.css': '<%= csslint.src.projectCss %>',
'css/bootstrap.min.css': 'css/bootstrap.css'
}
}
},
sass: {
options: {
style: 'compressed',
precision: 5
},
files: {
'css/style.css': '<%= csslint.src.project %>'
}
},
uglify: {
project: {
options: {
// banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files: {
"js/script.min.js": ["<%= jshint.project.src %>"]
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
// grunt.loadNpmTasks("grunt-htmlhint");
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.registerTask("min", ["csslint", "cssmin","jshint", "uglify"]);
grunt.registerTask("default", ["watch"]);
};
package.json
{
"private": true,
"name": "soroush-project",
"title": "best practices for your project",
"description": "masoud ui tasks",
"author": "Masoud Soroush",
"homepage": "http://soroush.co",
"version": "1.0.0",
"scripts": {},
"engines": {
"node": ">=0.10"
},
"dependencies": {
"jquery": ">=1.7"
}
}
我的问题在哪里?
最佳答案
看起来您将files
设置放在了任务而不是目标中。所有Grunt任务都必须至少有一个目标才能运行,在这种情况下,目标名为“文件”(而不是实际使用目标和嵌套的files
选项)。尝试这个:
sass: {
allstyles: { // <-- you needed another level
options: {
style: 'compressed',
precision: 5
},
files: {
'css/style.css': '<%= csslint.src.project %>'
}
}
},
仅供参考,您的“ csslint”任务也需要一个目标。
关于css - grunt dos not created css(从ass到css):完成,没有错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27682340/