What is “{.tmp,app} ” in Yeoman generator?

2019-04-04 14:01发布

问题:

I am getting started with the Yeoman workflow, but I can't seem to completely understand the "alternate search path" for the usemin task in the index.html file. For example, there are 2 blocks generated with the 'yo angular' command:

<!-- 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 -->

vs.

<!-- 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 -->

Why does the second one have the {.tmp, app} "alternate search path" (what does it mean)? Thanks in advance.

回答1:

<!-- build:js({.tmp,app}) scripts/scripts.js -->
<!-- endbuild -->

In yeoman js scripts are available in the app folder, but when the user is using CoffeeScript grunt task will convert .coffee files to .js files. Those generated .js files will be available in .tmp folder with the same folder structure.

In those condition ({.tmp,app}) is used to tell grunt-usemin to search both in app and .tmp folder, so that the build won't miss out generated js files.

scripts/scripts.js is the destination file after the build.