这是我的相关部分index.html
:
<!-- build:js scripts/scripts.js -->
<script src="scripts/vendor/jquery.js"></script>
<script src="scripts/vendor/bootstrap.min.js"></script>
<script src="scripts/vendor/handlebars.runtime.js"></script>
<script src="scripts/vendor/ember.js"></script>
<script src="scripts/vendor/ember-data.js"></script>
<script src="scripts/templates.js"></script>
<script src="scripts/neuterapp.js"></script>
<!-- endbuild -->
(但最后两个条目是错误的,这实际上是我的问题)
这是相关部分Gruntfile.js
:
useminPrepare: {
html: '<%= yeoman.app %>/index.html',
options: {
dest: '<%= yeoman.dist %>'
}
},
usemin: {
html: ['<%= yeoman.dist %>/*.html'],
css: ['<%= yeoman.dist %>/styles/*.css'],
options: {
dirs: ['<%= yeoman.dist %>']
}
},
我遇到的问题是templates.js
和都是生成的文件,neuterapp.js
所以它们不在.<%= yeoman.app %>/scripts
<%= yeoman.dist %>/scripts
这是我的(简化的)目录结构:
webapp/
├── app
│ ├── app.js <--- for neuter
│ ├── controllers
│ ├── index.html
│ ├── models
│ ├── routes
│ ├── scripts
│ │ └── vendor <--- for usemin
│ ├── templates <--- for ember_templates
│ │ ├── template1.hbs
│ │ └── template2.hbs
│ └── views
├── dist
│ ├── index.html
│ └── scripts
│ ├── neuterapp.js <--- this must also be used for usemin!!!
│ └── templates.js <--- this must also be used for usemin!!!
└── Gruntfile.js
我怎么知道usemin
包含一些生成的文件?
如果需要,这些是 和 的neuter
配置ember_templates
:
neuter: {
options: {
includeSourceURL: true
},
'<%= yeoman.dist %>/scripts/neuterapp.js': '<%= yeoman.app %>/app.js'
},
ember_templates: {
compile: {
options: {
templateName: function (sourceFile) {
return sourceFile.replace(/app\/templates\//, ''); // <%= yeoman.dist %>/scripts/
}
},
files: {
'<%= yeoman.dist %>/scripts/templates.js': [
'<%= yeoman.app %>/templates/**/*.hbs'
]
}
}
},