我正在使用yeoman的骨干生成器,我运行了这个:
bower install backbone.localStorage -S
Run Code Online (Sandbox Code Playgroud)
我手动必须将其插入index.html:
<script src="bower_components/backbone.localStorage/backbone.localStorage.js"></script>
Run Code Online (Sandbox Code Playgroud)
凉亭有没有办法自动插入<script>标签?我认为凉亭的部分好处是不必弄清楚包含你的脚本的顺序是什么?
mvi*_*okx 43
赶紧跑
grunt bowerInstall
Run Code Online (Sandbox Code Playgroud)
凉亭安装后
Kat*_*ato 16
您可以使用wiredep将依赖项从bower推送到HTML代码中.这是运行时生成器角度使用的方法yo angular:
var wiredep = require('wiredep');
wiredep({
directory: 'app/bower_components',
bowerJson: JSON.parse(fs.readFileSync('./bower.json')),
ignorePath: 'app/',
htmlFile: 'app/index.html',
cssPattern: '<link rel="stylesheet" href="{{filePath}}">'
});
Run Code Online (Sandbox Code Playgroud)
Bower不会为这样的特定功能添加支持,但很快就会允许您指定在'bower安装'新包后执行的操作.这将被称为"postinstall",类似于npm.
然而,与此同时,我创建了一个库以帮助解决这个问题.由于您使用的是yeoman,只需将"grunt-bower-install"添加为npm'devDependency',然后按照此处的说明操作:https://github.com/stephenplusplus/grunt-bower-install.
| 归档时间: |
|
| 查看次数: |
36620 次 |
| 最近记录: |