-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
executable file
·115 lines (101 loc) · 4.04 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
/*jshint node:true, laxbreak:true */
'use strict';
module.exports = function(grunt) {
// -- Plugins --------------------------------------------------------------
// Uncomment the next line to report the Grunt execution time (for optimization, etc)
// require('time-grunt')(grunt);
// Intelligently lazy-loads tasks and plugins as needed at runtime.
require('jit-grunt')(grunt, { versioncheck: 'grunt-version-check' })({ 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({
// Load `package.json`so we have access to the project metadata such as name and version number.
pkg: require('./package.json'),
// Load `build-env.js`so we have access to the project environment configuration and constants.
env: require('./build-env'),
// Removes generated files and directories. Useful for rebuilding 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.
// For LiveReload, download browser extension at http://go.livereload.com/extensions
watch: {
options: {
livereload: {
// Default port for LiveReload
// *Will not work if multiple users run using the same port on a shared server*
port: 35729
}
},
watchVendor: {
files: ['<%= env.DIR_BOWER %>/**/*'],
tasks: [
'buildScripts',
'buildStyles'
]
},
watchMarkup: {
files: ['<%= env.DIR_SRC %>/**/*.{hbs,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/**/*'],
tasks: ['buildStyles']
},
watchScripts: {
files: ['<%= env.DIR_SRC %>/assets/scripts/**/*'],
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'] :
// 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(
'lint',
'Validate code syntax.',
['lintScripts']
);
grunt.registerTask(
'inject',
'Inject 3rd-party library references from bower.json into source code.',
['injectStyles', 'injectScripts']
);
grunt.loadNpmTasks('grunt-contrib-watch');
};