前端构建系统相当新,我正在Yeoman生成有角度的装配网站。它使用Gruntfile.js来包含bower.json,它声明了以下内容 - 请注意我添加了Foundation及其依赖项:
{
"name": "mercurysocialclub",
"version": "0.0.0",
"dependencies": {
"angular": "^1.3.0",
"angular-animate": "^1.3.0",
"angular-cookies": "^1.3.0",
"angular-resource": "^1.3.0",
"angular-route": "^1.3.0",
"angular-sanitize": "^1.3.0",
"angular-touch": "^1.3.0",
"foundation": "^5.5.0",
"fastclick": "^1.0.6",
"modernizr": "^2.8.3"
},
"devDependencies": {
"angular-mocks": "^1.3.0"
},
"appPath": "app",
"moduleName": "mercurysocialclubApp"
}
全部退房。从终端运行grunt --force之后,构建在/app/index.html中生成以下脚本调用,并导出/dist/vendor.js并且所有调用都已连接:
Configuration is now:
concat:
{ generated:
{ files:
[ { dest: '.tmp/concat/scripts/vendor.js',
src:
[ 'bower_components/modernizr/modernizr.js',
'bower_components/jquery/dist/jquery.js',
'bower_components/angular/angular.js',
'bower_components/angular-animate/angular-animate.js',
'bower_components/angular-cookies/angular-cookies.js',
'bower_components/angular-resource/angular-resource.js',
'bower_components/angular-route/angular-route.js',
'bower_components/angular-sanitize/angular-sanitize.js',
'bower_components/angular-touch/angular-touch.js',
'bower_components/fastclick/lib/fastclick.js',
'bower_components/jquery.cookie/jquery.cookie.js',
'bower_components/jquery-placeholder/jquery.placeholder.js',
'bower_components/foundation/js/foundation.js' ] },
{ dest: '.tmp/concat/scripts/scripts.js',
但是,基金会轨道脚本似乎未包括在内。我无法弄清楚的是如何使用bower.json或Gruntfile.js显式包含Foundation依赖脚本。
此解决方案似乎未包括正确写入: http://foundation.zurb.com/forum/posts/21949-compiling-javascript-in-the-gruntfile
在其他任何地方,我尝试包含要么被覆盖,要么无法访问grunt配置之外的bower_components目录。
我知道如何告诉Grunt / Bower将脚本包含在:bower_components / foundation / js / foundation / foundation。*。js
- = - = - = - = - = -
此外,在此方案中声明Foundation初始化也失败了!
<script>
$(document).ready(function(){
$(document).foundation('orbit', 'reflow');
}):
</script>
虽然如果我从终端运行此命令,一切都按预期工作:
$(document).foundation('orbit', 'reflow');
答案 0 :(得分:0)
这里的秘诀是我需要包含$(文件).foundation('orbit','reflow');在我的主控制器中,而不是在index.html中。
在我的构建中使用以下块允许我包括轨道js。
<!-- build:js(.) scripts/foundation.js -->
<!-- foundation:js -->
<script src="bower_components/foundation/js/foundation/foundation.orbit.js"></script>
<!-- endfoundation -->
<!-- endbuild -->