-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
156 lines (119 loc) · 3.93 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
154
155
156
/* jshint node: true */
module.exports = function(grunt) {
var path = require('path'),
_ = grunt.util._;
// Loads tasks for package.json and options from `tasks/options`
var config = require('load-grunt-config')(grunt, {
defaultPath: path.join(__dirname, 'tasks/options'),
configPath: path.join(__dirname, 'tasks/custom'),
init: false
});
// Loads tasks in `tasks` folder
grunt.loadTasks('tasks');
grunt.registerTask('createResultDirectory', function() {
grunt.file.mkdir('tmp/result');
});
// Environment
config.env = process.env;
// Default Task
grunt.registerTask(
'default',
"Build (in debug mode) & test your application.",
['test']
);
// Release Task
grunt.registerTask(
'dist',
"Build a minified & production-ready version of your app.",
['clean:dist', 'build:dist', 'copy:assemble', 'createDistVersion']
);
// Server Tasks
grunt.registerTask(
'server',
"Run your server in development mode, auto-rebuilding when files change.",
['clean:debug', 'build:debug', 'serve:debug', 'watch']
);
grunt.registerTask(
'server:dist',
"Build and preview a minified & production-ready version of your app.",
['dist', 'serve:dist:keepalive']
);
// Testing Tasks
grunt.registerTask(
'test',
"Run your apps's tests once. Uses Google Chrome by default.",
['clean:debug', 'build:debug', 'testem:ci:basic']
);
grunt.registerTask(
'test:ci',
"Run your app's tests in PhantomJS. For use in continuous integration.",
['clean:debug', 'build:debug', 'testem:ci:basic' ]
);
grunt.registerTask(
'test:browsers',
"Run your app's tests in multiple browsers.",
['clean:debug', 'build:debug', 'testem:ci:browsers']
);
grunt.registerTask(
'test:server',
"Start the test server and the standard development server.",
['clean:debug', 'build:debug', 'testem:run:basic', 'serve:debug', 'watch']
);
// Build Tasks
grunt.registerTask('build:dist', [
'createResultDirectory', // Create directoy beforehand, fixes race condition
'concurrent:buildDist', // Executed in parallel, see config below
]);
grunt.registerTask('build:debug', [
'jshint:tooling',
'createResultDirectory', // Create directoy beforehand, fixes race condition
'concurrent:buildDebug', // Executed in parallel, see config below
]);
grunt.registerTask('createDistVersion', [
'useminPrepare', // Configures concat, cssmin and uglify
'concat', // Combines css and javascript files
'cssmin', // Minifies css
'uglify', // Minifies javascript
'imagemin', // Optimizes image compression
// 'svgmin',
'copy:dist', // Copies files not covered by concat and imagemin
'rev', // Appends 8 char hash value to filenames
'usemin', // Replaces file references
'htmlmin:dist' // Removes comments and whitespace
]);
// Parallelize most of the build process
_.merge(config, {
concurrent: {
buildDist: [
"buildTemplates:dist",
"buildScripts",
"buildStyles",
"buildIndexHTML:dist"
],
buildDebug: [
"buildTemplates:debug",
"buildScripts",
"buildStyles",
"buildIndexHTML:debug"
]
}
});
// Templates
grunt.registerTask('buildTemplates:dist', ['emberTemplates:dist']);
grunt.registerTask('buildTemplates:debug', ['emberTemplates:debug']);
// Javascript
grunt.registerTask('buildScripts', [
'jshint:app',
'jshint:tests',
'copy:javascriptToTmp',
'transpile',
'concat_sourcemap'
]);
// CSS
grunt.registerTask('buildStyles', ['less:compile', 'copy:cssToResult']);
// HTML
grunt.registerTask('buildIndexHTML:dist', ['preprocess:indexHTMLDistApp', 'preprocess:indexHTMLDistTests']);
grunt.registerTask('buildIndexHTML:debug', ['preprocess:indexHTMLDebugApp', 'preprocess:indexHTMLDebugTests']);
// Initialize the config object for the current project.
grunt.initConfig(config);
};