This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
forked from neobadger/google-apps-scripts-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
114 lines (103 loc) · 2.88 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
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
uses_defaults: {}
},
/*********************************
* Import Modules
*********************************/
import: {
options: {},
script: {
src: 'app/app.js',
dest: 'script/script.js'
},
module: {
src: 'app/modules.js',
dest: 'script/modules.js'
}
},
/*********************************
* Concatenate Files
*********************************/
concat: {
// Modules only, split output.
modules: {
src: ['app/**/*.js', '!app/app.js'],
dest: 'script/modules.js'
},
// Main only, split output.
main: {
src: ['app/app.js'],
dest: 'script/script.js'
},
// All app files, single script output.
all: {
src: ['app/**/*.js'],
dest: 'script/script.js'
}
},
/*********************************
* Transpile Files
*********************************/
babel: {
options: {
sourceMap: false,
presets: ['@babel/preset-env']
},
split: {
files: {
'script/script.js': 'script/script.js',
'script/modules.js': 'script/modules.js'
}
},
main: {
files: {
'script/script.js': 'script/script.js'
}
},
manual: {
files: {
'script/script.js': 'app/app.js',
'script/modules.js': 'script/modules.js'
}
}
},
/*********************************
* Watch for Changes to Dev Files
*********************************/
watch: {
scripts: {
files: ['app/app.js'], // <-- change this based on your dev workflow
tasks: ['default'], // <-- change this based on your dev workflow
options: {
spawn: false
}
}
}
});
/*********************************
* Load Grunt Plugins
*********************************/
grunt.loadNpmTasks('grunt-import');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
/*********************************
* Define Tasks
*********************************/
// Default task(s).
grunt.registerTask('default', ['import:script', 'babel:main']);
// Import modules into `module.js` file and transpile `app,js` and `module.js` .
grunt.registerTask('export_manual', ['import:module', 'babel:manual']);
// Break the main script and modules into two separate files, and transpile them.
grunt.registerTask('export_modular', [
'concat:modules',
'concat:main',
'babel:split'
]);
// Bundles all files and transpile the content
grunt.registerTask('export_all', ['concat:all', 'babel:main']);
};