0

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

html.tpl.php我已经设置了 grunt-wiredep 以自动在我的文件中注入我的凉亭组件,如下所示:

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 任务,但随后我收到未安装我的依赖项的错误。

任何人都可以帮助我吗?

4

1 回答 1

0

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

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}}"/>',
                }
            }
        }
    }
}
于 2015-11-05T15:12:05.270 回答