-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
119 lines (108 loc) · 3.92 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
html2js: {
dist: {
options: {
base: '.',
module: 'template-<%= pkg.name %>-<%= pkg.version %>.html'
},
files: [{
expand: false,
src: ['templates/**/*.html'],
dest: 'build/<%= pkg.name %>.html.js'
}]
}
},
uglify: {
dist: {
files: {
'build/<%= pkg.name %>.min.js': ['js/<%= pkg.name %>.js']
}
}
},
concat: {
options: {
banner:
'/* \n' +
'* Name: <%= grunt.config.get("pkg.name") %> \n' +
'* Description: <%= grunt.config.get("pkg.description") %> \n' +
'* Version: <%= grunt.config.get("pkg.version") %> \n' +
'* Author: <%= grunt.config.get("pkg.author") %> \n' +
'* Homepage: <%= grunt.config.get("pkg.homepage") %> \n' +
'* License: <%= grunt.config.get("pkg.license") %> \n' +
'* Date: <%= grunt.template.today("yyyy-mm-dd") %> \n' +
'*/ \n',
process: function (src, filepath) {
if (filepath === 'build/' + grunt.config.get('pkg.name') + '.min.js' || filepath === 'js/' + grunt.config.get('pkg.name') + '.js') {
var newStr = 'template-' + grunt.config.get('pkg.name') + '-' + grunt.config.get('pkg.version') + '.html';
return src.replace('[]', '["' + newStr + '"]');
}
return src;
}
},
dist_min: {
files: {
'dist/min/<%= pkg.name %>-<%= pkg.version %>.min.js': ['build/**/*.html.js', 'build/**/*.min.js']
}
},
dist_debug: {
files: {
'dist/debug/<%= pkg.name %>-<%= pkg.version %>.js': ['build/**/*.html.js', 'js/**/*.js']
}
}
},
cssmin: {
target: {
files: [{
expand: true,
cwd: 'css',
src: '*.css',
dest: 'build',
ext: '.min.css'
}]
}
},
copy: {
dest_min: {
files: [{
src: 'build/<%= pkg.name %>.min.css',
dest: 'dist/min/<%= pkg.name %>-<%= pkg.version %>.min.css'
}]
},
dest_debug: {
files: [{
src: 'css/<%= pkg.name %>.css',
dest: 'dist/debug/<%= pkg.name %>-<%= pkg.version %>.css'
}]
}
},
karma: {
unit: {
configFile: 'karma.conf.js',
background: false,
browsers: ['Firefox']
}
},
clean: {
all: {
src: ['build', 'coverage']
},
build: {
src: ['build']
},
coverage: {
src: ['coverage']
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-html2js');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-karma');
grunt.registerTask('default', ['clean:all', 'html2js', 'uglify', 'concat', 'cssmin', 'copy', 'clean:build']);
grunt.registerTask('test', ['clean:all', 'html2js', 'uglify', 'concat', 'cssmin', 'copy', 'karma', 'clean:build']);
};