-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
88 lines (68 loc) · 2.06 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
'use strict';
module.exports = function (grunt) {
// configurable paths for the app
const appConfig = {
pkg : grunt.file.readJSON('package.json'),
dist : 'app/assets/dist',
build : 'app/assets/build',
src : 'app/assets/src',
compressFileName: 'archive.zip'
};
// project configuration
grunt.initConfig({
// package.json
pkg: appConfig.pkg,
// project settings
theme: appConfig
});
// load the Grunt plugins
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
// Load grunt tasks from a directory
require('grunt-config-dir')(grunt, {
configDir: require('path').resolve('grunt')
});
// show grunt task time
require('time-grunt')(grunt);
grunt.registerTask('lint', [
'compress',
'jshint'
]);
grunt.registerTask('build', [
'clean',
'copy',
'sass',
'cssmin',
'uglify'
]);
grunt.registerTask('pro', [
'update_manifest:0',
'prompt',
'build',
'compress',
'notify:watch_compress'
]);
grunt.registerTask('dev', [
'update_manifest:1',
'build',
'notify:watch_dev',
'watch'
]);
grunt.registerTask('default', [
'pro'
]);
grunt.registerTask('update_manifest', function (is_not_production) {
var manifestFile = 'app/manifest.json',
manifestObject = grunt.file.readJSON(manifestFile);//get file as json object
manifestObject.background.scripts = [
'assets/dist/js/background.min.js'
];
if (typeof is_not_production === 'undefined') {
is_not_production = 1;
}
is_not_production = parseInt(is_not_production);
if (is_not_production) {
manifestObject.background.scripts.push('assets/src/js/chromereload.js');
}
grunt.file.write(manifestFile, JSON.stringify(manifestObject, null, 4));//serialize it back to file
});
};