-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
194 lines (177 loc) · 5.31 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
module.exports = function (grunt) {
require("time-grunt")(grunt);
// 1. Configuration
grunt.initConfig({
// pass in options to plugins, references to files, etc.
json_minification: {
dist: {
files: [
{
expand: true,
cwd: "tenlists/utils",
src: ["ten_lists.json", "ten_lists_slim.json"],
dest: "tenlists/data",
ext: ".json",
},
],
},
},
copy: {
fa: {
expand: true,
cwd: "node_modules/font-awesome/",
src: ["css/*.css", "fonts/*"],
dest: "tenlists/webapp/ten_lists/static/vendors/font-awesome/",
},
bootstrap: {
expand: true,
cwd: "node_modules/bootstrap/dist/",
src: ["css/*.css", "js/*.js"],
dest: "tenlists/webapp/ten_lists/static/vendors/bootstrap/",
},
// balloon_css: {
// expand: true,
// cwd: "node_modules/balloon-css/",
// src: ["*.css"],
// dest: "tenlists/webapp/ten_lists/static/vendors/balloon-css/"
// },
// bootswatch: {
// expand: true,
// cwd: "node_modules/bootswatch/dist/",
// src: ["**/*", "!**/*.scss"],
// dest: "tenlists/webapp/ten_lists/static/vendors/bootswatch/"
// },
// holderjs: {
// expand: true,
// cwd: "node_modules/holderjs/",
// src: ["holder.js", "holder.min.js"],
// dest: "tenlists/webapp/ten_lists/static/vendors/holderjs/"
// },
jquery: {
expand: true,
cwd: "node_modules/jquery/dist/",
src: ["**/*", "!*.map"],
dest: "tenlists/webapp/ten_lists/static/vendors/jquery/",
},
moment: {
expand: true,
cwd: "node_modules/moment/min/",
src: ["**/*", "!*.map"],
dest: "tenlists/webapp/ten_lists/static/vendors/moment/",
},
},
cssmin: {
dist: {
files: [
{
expand: true,
cwd: "tenlists/webapp/ten_lists/static/css/",
src: ["custom.css"],
dest: "tenlists/webapp/ten_lists/static/css/",
ext: ".min.css",
},
],
},
},
uglify: {
dist: {
files: [
{
expand: true,
cwd: "tenlists/webapp/ten_lists/static/js/",
src: ["custom.js"],
dest: "tenlists/webapp/ten_lists/static/js/",
ext: ".min.js",
},
],
},
},
watch: {
css: {
files: ["tenlists/webapp/ten_lists/static/css/custom.css"],
tasks: ["cssmin"],
},
js: {
files: ["tenlists/webapp/ten_lists/static/js/custom.js"],
tasks: ["uglify"],
},
},
clean: {
dist: ["tenlists/webapp/ten_lists/static/vendors/*"],
},
browserSync: {
dev: {
bsFiles: {
src: [
"tenlists/webapp/ten_lists/static/css/*.css",
"tenlists/webapp/ten_lists/static/js/*.js",
"tenlists/webapp/ten_lists/static/vendors/**/*.css",
"tenlists/webapp/ten_lists/static/vendors/**/*.js",
"tenlists/webapp/ten_lists/templates/**/*.html",
"tenlists/webapp/ten_lists/**/*.py",
],
},
options: {
watchTask: true,
// https://www.browsersync.io/docs/options/#option-proxy
proxy: {
target: "web:8000",
proxyReq: [
function (proxyReq, req) {
// Assign proxy "host" header same as current request at Browsersync server
proxyReq.setHeader("Host", req.headers.host);
},
],
},
port: 3000,
ui: {
port: 3001,
},
localOnly: true,
// Wait for 0.3 seconds before any browsers should try to inject/reload a file
reloadDelay: 300,
// Wait 0.5 seconds after a reload event before allowing more
reloadDebounce: 500,
// Don't show any notifications in the browser.
notify: false,
// Stop the browser from automatically opening
open: false,
},
},
},
});
// 2. Load Plugins
grunt.loadNpmTasks("grunt-json-minification");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-uglify-es");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-browser-sync");
grunt.loadNpmTasks("grunt-newer");
// 3. Register Tasks
// grunt.registerTask('run', function(){
// console.log('I am Running');
// });
// grunt.registerTask('walk', function(){
// console.log('I am Walking');
// });
// grunt.registerTask('all', ['run', 'walk']);
grunt.registerTask("compress-json", ["json_minification"]);
grunt.registerTask("cp", ["newer:copy"]);
grunt.registerTask("css-x", ["newer:cssmin"]);
grunt.registerTask("js-x", ["newer:uglify"]);
grunt.registerTask("rm", ["clean"]);
grunt.registerTask("all", ["cp", "css-x", "js-x"]);
grunt.registerTask("compress", ["css-x", "js-x"]);
// default task
grunt.registerTask("default", [
"rm",
"cp",
"css-x",
"js-x",
"browserSync",
"watch",
]);
grunt.registerTask("sync", ["browserSync", "watch"]);
};