我使用 Yeoman (v1.x) 和 grunt (v0.4.2) 构建 Angular 项目。 build
任务连接了我所有的 app/script
JS 文件,但它没有连接我所有的依赖文件,因此我构建的 index.html 进行了这些调用:
<script src="components/angular-unstable/angular.js"></script>
<script src="components/jquery/jquery.js"></script>
<script src="components/angular-resource/angular-resource.js"></script>
<script src="components/bootstrap/js/bootstrap-dropdown.js"></script>
<script src="components/moment/moment.js"></script>
<script src="components/underscore/underscore.js"></script>
<!-- xxxxxbuild:js scripts/scripts.js -->
<script src="scripts/274baf7d.scripts.js"></script>
我希望我的项目使用的所有组件,即 angular.js
、jquery.js
等等,都在 scripts.js 中
。重新配置 GruntFile 是否容易?还是出于实际原因默认情况下不这样做?
最佳答案
是的,这很容易配置。只需在传递 grunt concat
任务的源代码中添加 vendor 脚本。
// Project configuration.
grunt.initConfig({
concat: {
dist: {
src: ['vendors/**/*.js', 'scripts/**/*.js'],
dest: 'built.js'
}
}
});
关于javascript - 使用 grunt 连接所有 vendor 的 javascript 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16377674/