【问题标题】:grunt-sass does not compile bootstrap-sassgrunt-sass 不编译 bootstrap-sass
【发布时间】:2017-03-16 09:41:44
【问题描述】:

我尝试使用纯 nodejs 和 grunt 编译 boostrap-sass。所以,没有红宝石,轨道上的红宝石或宝石。

我的 package.json:

{
  "name": "myProject",
  "version": "1.0.0",
  "dependencies": {
    "grunt": "^1.0.1",
    "grunt-bootlint": "^0.10.1",
    "grunt-cli": "^1.2.0",
    "grunt-contrib-compress": "^1.3.0",
    "grunt-contrib-concat": "^1.0.1",
    "grunt-contrib-cssmin": "^1.0.2",
    "grunt-contrib-uglify": "^2.0.0",
    "grunt-sass-lint": "^0.2.0",
    "grunt-contrib-jshint": "^1.0.0"
  },
  "devDependencies": {
    "bootstrap-sass": "^3.3.7",
    "grunt-sass": "^1.2.1",
    "node-sass": "^3.10.1",
    "typescript": "^2.0.6",
    "typings": "^1.5.0"
  }
}

我的 Gruntfile.js:

module.exports = function (grunt)
{
    grunt.loadNpmTasks("grunt-sass");
    grunt.loadNpmTasks("grunt-sass-lint");
    grunt.loadNpmTasks("grunt-bootlint");
    grunt.loadNpmTasks("grunt-contrib-jshint");

    var relaxerrors = [
        "App/Mvc/views/notallowed.phtml",
        "App/Mvc/views/ajax/*.phtml",
        "App/Mvc/views/backend/*.phtml"
    ];

    grunt.initConfig({
            sass: {
                options: {
                    includePaths: ["node_modules/bootstrap-sass/assets/stylesheets/bootstrap"],
                    precision: 10,
                    sourcemap: "inline",
                    trace: true,
                    unixNewlines: true
                },
                dist: {
                    files: {
                        "web/assets/styles/frontend.min.css": "assets/styles/index.scss",
                        "web/assets/styles/backend.min.css": "assets/styles/dashboard.scss",
                        "web/assets/styles/bootstrap.min.css": "node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss"
                    }
                }
            },
            sasslint: {
                target: [ "assets/styles/*.scss" ]
            },
            jshint: {
                files: [ "assets/js/*.js" ],
                options: {
                    globals: {
                        jquery: true
                    }
                }
            },
            bootlint: {
                options: {
                    stoponerror: true,
                    showallerrors: true,
                    stoponwarning: false,
                    relaxerror: {
                        "E001": relaxerrors,
                        "W001": relaxerrors,
                        "W002": relaxerrors,
                        "W003": relaxerrors,
                        "W005": relaxerrors
                    }
                },
                files: [ "App/Mvc/views/*.phtml", "App/Mvc/views/*.html" ]
            }
        }
    );

    grunt.registerTask("validate:styles", [ "sasslint" ]);
    grunt.registerTask("validate:js", [ "jshint" ]);
    grunt.registerTask("validate:bootstrap", [ "bootlint" ]);
    grunt.registerTask("validate:all", [ "validate:bootstrap", "validate:styles", "validate:js" ]);
    grunt.registerTask("build:styles", [ "validate:styles", "sass" ]);
};

我是这样称呼它的:

grunt build:styles --force --verbose

这显示了以下输出:

Running "sass" task

Running "sass:dist" (sass) task
Verifying property sass.dist exists in config...OK
Files: assets/styles/index.scss -> web/assets/styles/frontend.min.css
Files: assets/styles/dashboard.scss -> web/assets/styles/backend.min.css
Files: node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss -> web/assets/styles/bootstrap.min.css
Options: precision=10, includePaths=["node_modules/bootstrap-sass/assets/stylesheets/bootstrap"], sourcemap="inline", trace, unixNewlines
Options: precision=10, includePaths=["node_modules/bootstrap-sass/assets/stylesheets/bootstrap"], sourcemap="inline", trace, unixNewlines
Options: precision=10, includePaths=["node_modules/bootstrap-sass/assets/stylesheets/bootstrap"], sourcemap="inline", trace, unixNewlines
Writing web/assets/styles/backend.min.css...OK
Writing web/assets/styles/frontend.min.css...OK

Done.

正如我们所见,它在引导时停止工作。任何帮助都会很棒。

【问题讨论】:

    标签: node.js sass gruntjs bootstrap-sass node-sass


    【解决方案1】:

    Sass 编译器不会编译任何以 _ 开头的文件,因为 _ 告诉它忽略它。

    您可以在部分部分下的http://sass-lang.com/guide 中参考它。

    【讨论】:

    • 哦,谢谢,我的错。简单地重命名解决了我的问题。我告诉编译器使用它忽略的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-26
    • 2017-04-16
    • 2014-03-14
    • 2016-10-27
    • 2014-05-04
    • 2015-02-14
    • 2015-01-02
    相关资源
    最近更新 更多