-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·119 lines (99 loc) · 4.11 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
/*jshint node:true, laxbreak:true */
'use strict';
module.exports = function(grunt) {
// -- Plugins --------------------------------------------------------------
// Uncomment the next line to have grunt report the time it takes for tasks
// to run so targets for optimization may be identified.
// require('time-grunt')(grunt);
// Intelligently lazy loads tasks and plugins as needed at runtime.
require('jit-grunt')(grunt)({ customTasksDir: 'tools/tasks' });
// -- Options --------------------------------------------------------------
// All builds are considered to be development builds, unless they're not.
grunt.option('dev', !grunt.option('stage') && !grunt.option('prod'));
// -- Configuration --------------------------------------------------------
grunt.initConfig({
// This will load the `package.json` file so we can have access to the
// project metadata such as name and version number.
pkg: require('./package.json'),
// This will load the `build-env.js` file so we can have access to the
// project environment configuration and constants.
env: require('./build-env'),
// Automatically removes generated files and directories. Useful for
// rebuilding the project with fresh copies of everything.
clean: {
options: {
force: '<%= env.UNSAFE_MODE %>'
},
dest: ['<%= env.DIR_DEST %>'],
docs: ['<%= env.DIR_DOCS %>'],
tmp: ['<%= env.DIR_TMP %>'],
installed: [
'tools/node-*',
'<%= env.DIR_BOWER %>',
'<%= env.DIR_NPM %>'
]
},
// Watches files and directories changes and runs associated tasks
// automatically. Compatible with the free LiveReload browser
// extensions to reload pages after watch tasks complete:
// http://go.livereload.com/extensions
watch: {
options: {
livereload: {
// Default port for LiveReload
// Note: will collide with an error message if others are
// running this on a shared server
port: 35729
}
},
watchMarkup: {
files: ['<%= env.DIR_SRC %>/**/*.html'],
tasks: ['buildMarkup']
},
watchStatic: {
files: [
'<%= env.DIR_SRC %>/**/.htaccess',
'<%= env.DIR_SRC %>/**/*.{php,rb,py,jsp,asp,aspx,cshtml,txt}',
'<%= env.DIR_SRC %>/assets/media/**',
],
tasks: ['buildStatic']
},
watchStyles: {
files: ['<%= env.DIR_SRC %>/assets/{scss,vendor}/**/*.{s,}css'],
tasks: ['buildStyles']
},
watchScripts: {
files: ['<%= env.DIR_SRC %>/assets/{scripts,vendor}/**/*.js'],
tasks: ['buildScripts']
}
}
});
// -- Tasks ----------------------------------------------------------------
grunt.registerTask('default', 'Run default tasks for the target environment.',
// Ran `grunt`
grunt.option('dev') ? ['build'] :
// Ran `grunt --stage`
grunt.option('stage') ? ['lint', 'build'] :
/**
* @todo includ testing by adding 'test' to the task
*/
// Ran `grunt --prod`
grunt.option('prod') ? ['lint', 'build', 'docs'] : []
);
grunt.registerTask('build', 'Compile source code and outputs to destination.',
['clean:dest', 'buildStatic', 'buildMarkup', 'buildStyles', 'buildScripts', 'clean:tmp']
);
grunt.registerTask('docs', 'Generate documentation.',
['clean:docs', 'docsScripts', 'clean:tmp']
);
grunt.registerTask('install', 'Run installation tasks.',
['installScripts']
);
grunt.registerTask('lint', 'Validate code syntax.',
['lintScripts']
);
grunt.registerTask('test', 'Execute tests.',
[]
);
grunt.loadNpmTasks('grunt-contrib-watch');
};