【问题标题】:grunt-bower-install won't include my css filesgrunt-bower-install 不会包含我的 css 文件
【发布时间】:2015-08-08 12:36:52
【问题描述】:

我对 bower 和 grunt 很陌生,所以基本的东西对我很不利。

根据documentation,我已经bower install --save bootstrap 并希望grunt-bower-install 更新我的js 和css 文件

它适用于 .js 文件,并且我已成功更新我的 index.html

<!-- bower:js -->
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<!-- endbower -->

但我的 dist/application.css 没有改变(只是空文件)

我的Gruntfile.coffee

module.exports = (grunt) ->
  grunt.initConfig
    pkg: grunt.file.readJSON('package.json')
    coffee:
      compile:
        files:
          'dist/application.js': 'app/assets/javascripts/*.coffee'
    bowerInstall:
      target:
        src: [
          'index.html'
          'dist/application.css'
        ]

  grunt.loadNpmTasks 'grunt-contrib-coffee'
  grunt.loadNpmTasks 'grunt-bower-install'

我应该如何处理我的 application.css 自动需要引导程序的 .css 文件?

【问题讨论】:

    标签: javascript gruntjs npm bower


    【解决方案1】:

    完成!

    只需将其放在head 标记中

    <!-- bower:css -->
    <!-- endbower -->
    <!-- bower:js -->
    <!-- endbower -->
    

    然后再次运行grunt bowerInstall

    【讨论】:

    • 我做到了,但它不起作用。您是否对配置进行了任何更改?
    • 没有。我没有改变任何东西
    • 这是最新版本的引导程序的一个错误,将其降级到 3.2 就可以了。
    【解决方案2】:

    更改位于 bower_modules/bootstrap/ 中的 bower.json 文件

    在末尾添加另一个属性:

    "overrides": {
        "bootstrap": {
            "main": [
                "dist/css/bootstrap.css"
            ]
        }
    }
    

    Override 告诉 bowerInstall 插件在 dist/css/bootstrap/css 中查找文件,以便在 html 文件中创建链接路径。

    第二个选项是通过在 bower.json 文件中指定引导程序的版本来将引导程序版本降级到 3.3.4。

    【讨论】:

      猜你喜欢
      • 2014-09-14
      • 2014-04-09
      • 2014-07-05
      • 1970-01-01
      • 2020-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-22
      相关资源
      最近更新 更多