grunt dos not create css(sass to css):完成,没有错误

时间:2014-12-29 01:24:54

标签: css sass gruntjs

我的操作系统是Ubuntu 14.04

我正在安装Nodejs,Ruby,NPM和sass版本:Sass 3.4.9(Selective Steve) 我在终端运行“grunt sass”任务!此任务正在运行并显示以下消息:

$ grunt sass
Running "sass:files" (sass) task

Done, without errors.

但是dos没有创建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"
    }

}

我的问题在哪里?

2 个答案:

答案 0 :(得分:0)

看起来您将files设置放在任务中而不是放在目标中。所有Grunt任务必须至少有一个目标才能运行,在您的情况下,目标命名为&#34;文件&#34; (而不是实际使用目标和嵌套的files选项)。试试这个:

sass: {
    allstyles: {  // <-- you needed another level
        options: {
            style: 'compressed',
            precision: 5
        },
        files: {
            'css/style.css': '<%= csslint.src.project %>'
        }
    }
},

和我们,你的&#34; csslint&#34;任务也需要一个目标。

答案 1 :(得分:-2)

如果Grunt报告“完成,没有错误”并且您没有看到预期的结果,请尝试单独运行lib。

就我而言,我的Gruntfile.js sass任务配置中有一个源路径错误...

当我运行grunt sass任务时,Grunt没有听到sass的潜在错误,只是报告“完成,没有错误”,实际上sass找不到源文件 - 没有css输出文件,但没有GRUNT错误任

我自己跑了sass而不是grunt sass任务,果然,sass抱怨:“errorno :: NOENT:没有这样的文件或目录@ rb_sysopen - src / sass / main.scss” - 我实际上有我的src / scss中的源代码,而不是src / sass。

浪费了45分钟试图谷歌sass的错误。 :d