【问题标题】:Wrong path to bower components after using grunt-wiredep使用 grunt-wiredep 后到凉亭组件的路径错误
【发布时间】:2015-11-05 14:14:46
【问题描述】:

我正试图让 Bower 在我的 Drupal 项目中工作。在我的项目的根目录中,我有一个 bower.json.bowerrc 文件。 Bower 组件正在sites/all/themes/mytheme/libraries 中安装。

我已经设置了 grunt-wiredep 来自动在我的 html.tpl.phpfile 中注入我的 bower 组件,如下所示:

wiredep: {
    task: {
        src: 'sites/all/themes/mytheme/templates/html.tpl.php'          
    }
}

当使用grunt wiredep时,插件将以下路径注入我的index.tpl.php文件:

<script src="../libraries/jquery/dist/jquery.js"></script>

它应该在哪里:

<script src="sites/all/themes/mytheme/libraries/jquery/dist/jquery.js"></script>

我尝试将directory: 'sites/all/thems/mytheme'; 添加到wiredep 任务中,但我收到未安装我的依赖项的错误。

谁能帮帮我?

【问题讨论】:

    标签: drupal gruntjs bower grunt-wiredep


    【解决方案1】:

    看来我现在可以正常工作了。这是我所做的:

    1) 我忽略了路径的第一部分:../

    2) 对于 html 文件,我替换了对 js 和 css 依赖项的引用。我在路径中添加了sites/all/themes/mytheme/

    这是我的wiredep任务现在的样子:

    wiredep: {
        task: {
            src: 'sites/all/themes/mytheme/templates/html.tpl.php',
            ignorePath: '../',
            fileTypes: {
                html: {
                    replace: {
                        js: '<script src="sites/all/themes/mytheme/{{filePath}}"></script>',
                        css: '<link rel="stylesheet" href="sites/all/themes/mytheme/{{filePath}}"/>',
                    }
                }
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多