forked from angular-wizard/angular-wizard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
153 lines (135 loc) · 4.8 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
'use strict';
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
config: {
distDir: 'dist',
srcDir: 'src',
testDir: 'test'
},
// Validate files with JSHint.
// https://github.com/gruntjs/grunt-contrib-jshint
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'src/**/*.js',
'test/*.js',
'Gruntfile.js'
]
},
// Compile Sass to CSS.
// https://github.com/gruntjs/grunt-contrib-sass
sass: {
dist: {
files: {
'<%= config.srcDir %>/css/<%= pkg.name %>.css': '<%= config.srcDir %>/scss/<%= pkg.name %>.scss'
}
}
},
// Run predefined tasks whenever watched file patterns are added, changed or deleted.
// https://github.com/gruntjs/grunt-contrib-watch
watch: {
css: {
files: '<%= config.srcDir %>/scss/*.scss',
tasks: ['sass']
}
},
// Delete the contents of the build directory before initiating a new build process.
// https://github.com/gruntjs/grunt-contrib-clean
clean: {
build: [
'<%= config.distDir %>' // Delete all files and folders in the `dist` directory.
],
postBuild: [
'<%= config.distDir %>/js', // Delete the `js` directory.
'<%= config.distDir %>/css' // Delete the `css` directory.
]
},
// Copy files and folders.
// https://github.com/gruntjs/grunt-contrib-copy
copy: {
build: {
cwd: '<%= config.srcDir %>', // cwd points to a directory the source files are relative to.
src: ['**', '!scss/**', '!index.html'], // src specifies the source files.
dest: '<%= config.distDir %>',
expand: true
},
},
// Converts AngularJS templates to JavaScript.
// https://github.com/karlgoldstein/grunt-html2js
// http://bahmutov.calepin.co/angular-templates.html
html2js: {
angularwizard: {
options: {
base: '<%= config.distDir %>'
},
src: [ '<%= config.distDir %>/js/*.html' ],
dest: '<%= config.distDir %>/js/<%= pkg.name %>.tpls.js'
},
},
// Concatenate files.
// https://github.com/gruntjs/grunt-contrib-concat
concat: {
js: {
options: {
// Replace all 'use strict' statements in the code with a single one at the top.
banner: "'use strict';\n",
process: function(src, filepath) {
return '// Source: ' + filepath + '\n' +
src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
},
},
src: [
// The JavaScript template file generated by `html2js` must come first for
// the try...catch statement in `src/js/app.js` to be fully functional.
// See `src/js/app.js`.
'<%= config.distDir %>/js/<%= pkg.name %>.tpls.js',
'<%= config.distDir %>/js/*.js',
],
dest: '<%= config.distDir %>/<%= pkg.name %>.js'
},
css: {
options: {},
src: [
'<%= config.distDir %>/css/*.css'
],
dest: '<%= config.distDir %>/<%= pkg.name %>.css'
}
},
// Minify files with UglifyJS
// https://github.com/gruntjs/grunt-contrib-uglify
uglify: {
options: {
report: 'min'
},
js: {
files: {
'<%= config.distDir %>/<%= pkg.name %>.min.js': '<%= config.distDir %>/<%= pkg.name %>.js'
}
}
},
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-html2js');
grunt.registerTask('default', [
'watch'
]);
grunt.registerTask('build', [
'jshint',
'clean:build',
'copy:build',
'html2js',
'concat',
'uglify',
'clean:postBuild',
]);
};