2015-07-28 79 views
0

我有一个咕噜任务配置(我正在工作现有的项目)。我不确定在哪里可以找到特定的任务。每次编译和构建后,我都会创建一个“index.html”文件并将其添加到“dist”文件夹中。但在我的index.html手动必须添加每次如下:Bootstrap.css没有被添加到index.html中

<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.css"> 

,也是 -

<base href="/"> 

对于AJS。

可能是什么问题?

我不想编辑bower.json,而是使用grunt任务。那我该怎么做呢?

我有以下几点:

VAR buildConfig = module.exports = {

// Wiredep options 
    wiredepOptions: { 

    // 
    // devDependencies: true, // <-- injects bower devDependencies 
    // 
    // exclude: [    // <-- List of patterns to exclude 
    //  
    //  /bootstrap\.js/ 
    // ] 

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

这使我的错误。我如何解决它?

+0

我们'必须看到你的gruntfile,或至少你注入你的css的部分 – Tom

+0

我是新来的grunt,这是一个现有的项目,那么我通常可以在哪里找到css注入? – Smitha

回答

0

这是因为main对象引导的bower.json提至less文件的引用不css

"main": [ 
    "less/bootstrap.less", 
    "dist/js/bootstrap.js" 
    ], 

Wiredep是繁重的任务,是负责注入这些资产,因此不知道在哪里CSS文件是。你可以在你的gruntfile.js在wiredep任务提供覆盖如下做到这一点:

wiredep: { 
    ..., 
    overrides: { 
     'bootstrap': { 
     'main': [ 
      'dist/js/bootstrap.js', 
      'dist/css/bootstrap.css' // Note this 
     ] 
     } 
    } 
    } 
}, 

再次运行grunt wiredep如预期的CSS文件将注入到你的HTML。

注:这是行不通的,除非你的HTML有这样的HTML注释

<!-- bower:css --> 
    The styles will be injected here 
<!-- endbower --> 
+0

但是,我只有 - bootstrap.css.map在我的dist和我已经有 - 地图:{ ..., src:['bower_components/**/*。css.map'], dest: 'dist/client/assets' }在我的gruntfile.js中 – Smitha

+0

检查你的bootstrap dist目录并搜索CSS文件。有缩小和未改版的版本。 –

0

我无法编辑Gruntfile解决,但在bower.json添加了这个:

"overrides": { 
    "bootstrap": { 
    "main": [ 
     "dist/css/bootstrap.css" 
     ] 
    } 
相关问题