grunt build从应用程序中删除d3.js和google字体 [英] grunt build removes d3.js and google fonts from application
问题描述
我已经用Yeoman配置了Angular应用程序,并且包括了许多JS库,例如d3.当我使用 grunt serve 查看应用程序时,该应用程序运行良好.但是,当我尝试使用 grunt build 构建它并打开生成的index.html时,该应用程序中断了,因为找不到D3.如果我手动添加 script 标记以将D3加载到最终的index.html中,则它开始工作,但是那不是它应该工作的方式,对吗?
I've configured my Angular app with Yeoman, and have included many JS libraries like d3. The application works fine when I use grunt serve to see the app. But when I try to build it using grunt build, and open the generated index.html, the app breaks because it cannot find D3. If I manually include the script tag for loading D3 in final index.html, then it starts working, but that's not how it's supposed to work, right?
grunt版本还会删除我包含在我的应用程序中的Google字体:
The grunt build also removes google Fonts which I've included in my app:
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
最终index.html中缺少此 link 标记
This link tag is missing from final index.html
我的bower.json看起来像这样:
My bower.json looks like this:
{
"name": "myApp",
"version": "0.0.0",
"main": "index.html",
"ignore": [
"**/.*",
"node_modules",
"bower_components"
],
"dependencies": {
"jquery": "~2.2",
"lodash": "~4.9",
"bootstrap": "^3.3.6",
"angular": "~1.5",
"angular-route": "~1.5",
"angular-animate": "~1.5",
"angular-resource": "~1.5",
"angular-cookies": "^1.5.7",
"angular-mocks": "~1.5",
"angular-bootstrap": "~1.3.1",
"moment": "~2.12",
"less.js": "~2.6",
"font-awesome": "~4.5",
"d3": "^3.5.17"
}
}
我尚未与其他库一起测试此问题,因为它们在构建后也可能无法正常工作.但是,角度,引导程序,超赞字体和LESS都可以正常工作.这让我发疯了!
I have not tested the issue with other libraries, as they might also be not working after the build. However, angular, bootstrap, font-awesome and LESS is working fine. This is driving me crazy!
推荐答案
我注意到我在gruntfile中使用dom_munger任务.它删除了所有带有data-concat ="false"的脚本.
I noticed that I was using dom_munger task in gruntfile. It removed all script with data-concat="false".
D3脚本被删除,因为它指定了data-concat ="false".
D3 script was being removed because it specified data-concat="false".
问题现在已解决.
这篇关于grunt build从应用程序中删除d3.js和google字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!