相关疑难解决方法(0)

如何在yeoman/grunt项目中自动包含脚本?

我有一个工作的自耕农项目.我正在使用grunt-usemin.

要包含javascripts,我这样做index.html:

<!-- build:js scripts/includes.js -->
<script src="/bower_components/jquery/jquery.min.js"></script>
<script src="/bower_components/underscore/underscore-min.js"></script>
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-route/angular-route.min.js"></script>
<script src="/bower_components/angular-resource/angular-resource.min.js"></script>
<script src="/bower_components/angular-sanitize/angular-sanitize.min.js"></script>
<script src="/bower_components/angular-ui-date/src/date.js"></script>
<script src="/bower_components/angulartics/src/angulartics.js"></script>
<script src="/bower_components/angulartics/src/angulartics-ga.js"></script>
<script src="/bower_components/jquery-ui/ui/jquery-ui.js"></script>
<script src="/assets/vendor/bootstrap.2.3.1.min.js"></script>
... a few more libs like that

<script src="/scripts/config.processed.js"></script>
<script src="/scripts/app.js"></script>

<script src="/scripts/controllers/first_controller.js"></script>
<script src="/scripts/controllers/second_controller.js"></script>
<script src="/scripts/controllers/third_controller.js"></script>
<script src="/scripts/controllers/fourth_controller.js"></script>
<script src="/scripts/controllers/fith_controller.js"></script>
<script src="/scripts/controllers/sixth_controller.js"></script>
<script src="/scripts/controllers/seventh_controller.js"></script>
... 20 more like that

<script src="/scripts/directives/first_directive.js"></script>
<script src="/scripts/directives/second_directive.js"></script>
<script src="/scripts/directives/third_directive.js"></script>
... 10 more like that

<script src="/scripts/services/first_service.js"></script>
<script src="/scripts/services/second_service.js"></script>
...

<script src="/scripts/filters/first_filter.js"></script>
<script src="/scripts/filters/second_filter.js"></script> …
Run Code Online (Sandbox Code Playgroud)

javascript gruntjs yeoman grunt-usemin

26
推荐指数
1
解决办法
2万
查看次数

Yeoman发电机中的"{.tmp,app}"是什么?

我开始使用Yeoman工作流程,但我似乎无法完全理解index.html文件中usemin任务的"备用搜索路径".例如,使用'yo angular'命令生成了2个块:

<!-- build:js scripts/modules.js -->
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<!-- endbuild -->
Run Code Online (Sandbox Code Playgroud)

<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/directives/multiselect.js"></script>
<!-- endbuild -->
Run Code Online (Sandbox Code Playgroud)

为什么第二个具有{.tmp,app}"备用搜索路径"(这是什么意思)?提前致谢.

gruntjs yeoman

12
推荐指数
1
解决办法
4048
查看次数

可以grount自动包含index.html中的所有js吗?

我是新来的咕噜声.我来自铁轨并进入角度.从我可以看到,grunt usemin可以替换<script src=...>构建指令,并在grunt构建期间用单个缩小的js替换它.这对于部署非常有用.

但是每当我在开发过程中添加新的角度控制器时,我也必须记住将它们添加到我的index.html.这是一个麻烦,如果我移动我的功能文件夹,我必须改变index.html中的所有src路径.

如果在开发中,grunt会观察我的全部src/**/*.js并自动将它们全部添加到index.html中,这将是很好的...类似于rails资产管道和资产清单,当你开发时只需要require_tree.您可以将文件放在任何位置,并且它可以自动使用.

对于咕噜咕噜的观察者,是否存在这样的现有解决方案或示例?谢谢

ruby-on-rails angularjs gruntjs grunt-usemin

9
推荐指数
2
解决办法
6439
查看次数