Skip to content

Commit 4491cb9

Browse files
committed
Embed template into final build
* updated build process to create a to js converted and minified template that is added to the directives $templateCache * updated the build process to provide a distribution with normal and minified versions of the directive with or without the included template (like angular-ui-bootstrap) * added new dev dependencies to package.json * adjust path to main file in bower.json
1 parent 2f6af17 commit 4491cb9

9 files changed

+653
-22
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ logs
99
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
1010
node_modules
1111
bower_components
12+
13+
tmp

Gruntfile.js

Lines changed: 76 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,68 @@ module.exports = function(grunt) {
88
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> <%= pkg.author.url %>\n' +
99
' * License: <%= pkg.license %>\n' +
1010
' */\n',
11-
11+
jshint: {
12+
all: [
13+
'./src/*.js', '*.js', '*.json'
14+
],
15+
options: {
16+
jshintrc: '.jshintrc'
17+
}
18+
},
19+
ngtemplates: {
20+
options: {
21+
module: 'angular-advanced-searchbox',
22+
htmlmin: {
23+
collapseBooleanAttributes: true,
24+
collapseWhitespace: true,
25+
removeAttributeQuotes: true,
26+
removeComments: true, // Only if you don't use comment directives!
27+
removeEmptyAttributes: true,
28+
removeRedundantAttributes: true,
29+
removeScriptTypeAttributes: true,
30+
removeStyleLinkTypeAttributes: true
31+
}
32+
},
33+
template: {
34+
src: ['src/*.html'],
35+
dest: 'tmp/templates.js'
36+
},
37+
},
38+
concat: {
39+
template: {
40+
options: {
41+
},
42+
src: ['src/<%= pkg.name %>.js', '<%= ngtemplates.template.dest %>'],
43+
dest: 'dist/<%= pkg.name %>-tpls.js'
44+
}
45+
},
46+
copy: {
47+
main : {
48+
files: [
49+
{
50+
src: ['src/<%= pkg.name %>.js'],
51+
dest: 'dist/<%= pkg.name %>.js'
52+
}
53+
]
54+
},
55+
template : {
56+
files: [
57+
{
58+
src: ['src/<%= pkg.name %>.html'],
59+
dest: 'dist/<%= pkg.name %>.html'
60+
}
61+
]
62+
}
63+
},
1264
uglify: {
1365
options: {
1466
banner: '<%= banner %>'
1567
},
16-
build: {
17-
src: 'src/<%= pkg.name %>.js',
18-
dest: 'build/<%= pkg.name %>.min.js'
68+
dist: {
69+
files: {
70+
'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js'],
71+
'dist/<%= pkg.name %>-tpls.min.js': ['dist/<%= pkg.name %>-tpls.js'],
72+
}
1973
}
2074
},
2175
cssmin: {
@@ -25,36 +79,39 @@ module.exports = function(grunt) {
2579
},
2680
minify: {
2781
src: 'src/<%= pkg.name %>.css',
28-
dest: 'build/<%= pkg.name %>.min.css'
82+
dest: 'dist/<%= pkg.name %>.min.css'
2983
}
3084
},
31-
copy: {
32-
template : {
33-
files: [
34-
{
35-
src: ['src/angular-advanced-searchbox.html'],
36-
dest: 'build/angular-advanced-searchbox.html'
37-
}
38-
]
85+
clean: {
86+
temp: {
87+
src: [ 'tmp' ]
3988
}
4089
},
41-
jshint: {
42-
all: [
43-
'./src/*.js', '*.json'
44-
],
90+
bump: {
4591
options: {
46-
jshintrc: '.jshintrc'
92+
files: ['package.json', 'bower.json'],
93+
updateConfigs: ['pkg'],
94+
commit: true,
95+
commitFiles: ['-a'],
96+
createTag: true,
97+
push: true,
98+
pushTo: 'origin'
4799
}
48100
}
49101
});
50102

51103
// Load the plugins
104+
grunt.loadNpmTasks('grunt-bump');
105+
grunt.loadNpmTasks('grunt-contrib-clean');
106+
grunt.loadNpmTasks('grunt-contrib-concat');
107+
grunt.loadNpmTasks('grunt-contrib-copy');
52108
grunt.loadNpmTasks('grunt-contrib-uglify');
53109
grunt.loadNpmTasks('grunt-contrib-cssmin');
54110
grunt.loadNpmTasks('grunt-contrib-jshint');
55111
grunt.loadNpmTasks('grunt-contrib-copy');
112+
grunt.loadNpmTasks('grunt-angular-templates');
56113

57114
// Default task(s).
58-
grunt.registerTask('default', ['jshint:all', 'uglify', 'cssmin', 'copy']);
115+
grunt.registerTask('default', ['clean', 'jshint:all', 'ngtemplates', 'concat', 'copy', 'uglify', 'cssmin']);
59116

60117
};

bower.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"Daniel Nauck <[email protected]>"
77
],
88
"description": "A directive for AngularJS providing a advanced visual search box",
9-
"main": "src/angular-advanced-searchbox.js",
9+
"main": [
10+
"dist/angular-advanced-searchbox.min.css",
11+
"dist/angular-advanced-searchbox-tpls.js"
12+
],
1013
"keywords": [
1114
"search",
1215
"angular",

0 commit comments

Comments
 (0)