Skip to content
This repository was archived by the owner on Mar 26, 2018. It is now read-only.

Commit b7b72b0

Browse files
committed
feat(app): add grunt-angular-templates to the build
Support using template cache for views instead of loading over http Closes #277
1 parent e60b1b5 commit b7b72b0

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

templates/common/root/_Gruntfile.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,16 @@ module.exports = function (grunt) {
317317
usemin: {
318318
html: ['<%%= yeoman.dist %>/{,*/}*.html'],
319319
css: ['<%%= yeoman.dist %>/styles/{,*/}*.css'],
320+
js: ['<%%= yeoman.dist %>/scripts/{,*/}*.js'],
320321
options: {
321322
assetsDirs: [
322323
'<%%= yeoman.dist %>',
323324
'<%%= yeoman.dist %>/images',
324325
'<%%= yeoman.dist %>/styles'
325-
]
326+
],
327+
patterns: {
328+
js: [[/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to images']]
329+
}
326330
}
327331
},
328332

@@ -386,12 +390,25 @@ module.exports = function (grunt) {
386390
files: [{
387391
expand: true,
388392
cwd: '<%%= yeoman.dist %>',
389-
src: ['*.html', 'views/{,*/}*.html'],
393+
src: ['*.html'],
390394
dest: '<%%= yeoman.dist %>'
391395
}]
392396
}
393397
},
394398

399+
ngtemplates: {
400+
dist: {
401+
options: {
402+
module: '<%= scriptAppName %>',
403+
htmlmin: '<%%= htmlmin.dist.options %>',
404+
usemin: 'scripts/scripts.js'
405+
},
406+
cwd: '<%%= yeoman.app %>',
407+
src: 'views/{,*/}*.html',
408+
dest: 'templateCache.js'
409+
}
410+
},
411+
395412
// ng-annotate tries to make the code safe for minification automatically
396413
// by using the Angular long form for dependency injection.
397414
ngAnnotate: {
@@ -424,7 +441,6 @@ module.exports = function (grunt) {
424441
'*.{ico,png,txt}',
425442
'.htaccess',
426443
'*.html',
427-
'views/{,*/}*.html',
428444
'images/{,*/}*.{webp}',
429445
'styles/fonts/{,*/}*.*'
430446
]
@@ -524,6 +540,7 @@ module.exports = function (grunt) {
524540
'useminPrepare',
525541
'concurrent:dist',
526542
'autoprefixer',
543+
'ngtemplates',
527544
'concat',
528545
'ngAnnotate',
529546
'copy:dist',

templates/common/root/_package.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"private": true,
33
"devDependencies": {
44
"grunt": "^0.4.5",
5+
"grunt-angular-templates": "^0.5.7",
56
"grunt-autoprefixer": "^2.0.0",
67
"grunt-concurrent": "^1.0.0",
78
"grunt-contrib-clean": "^0.6.0",<% if (coffee) { %>

0 commit comments

Comments
 (0)