css - grunt dos NOT create css (sass to css) : Done, 没有错误

标签 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.

但不创建 CSS 文件

配置 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"]);


};

包.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 任务都必须至少有一个要运行的目标,在您的情况下,目标被命名为"file"(而不是您实际使用目标和嵌套的 files 选项)。试试这个:

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

仅供引用,您的“csslint”任务还需要一个目标。

关于css - grunt dos NOT create css (sass to css) : Done, 没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27682340/

相关文章:

css - vh/% 单位和移动设备上的键盘

gruntjs - 如何结合使用 grunt-contrib-compass 和 grunt-contrib-cssmin

java - Grunt,Livereload 与 maven 和 jetty 服务器

node.js - grunt 安装时遇到问题

css - Flexbox:元素阴影不适用于顺序属性

css - 链接字体颜色问题

css - 在没有 React 的情况下使用 css-loader

html - LI 中带有图标图像的响应式文本宽度

css - SASS:基于属性的内容

ruby-on-rails - 预编译时的 Sass undefined variable