This repository has been archived by the owner on Jan 22, 2022. It is now read-only.
forked from Autodesk/3DViewerComponent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
238 lines (210 loc) · 6.55 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
// Generated on 2015-02-08 using generator-Far 0.11.0
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
var fs = require('fs');
// Define the configuration for all the tasks
grunt.initConfig({
//
//// Empties folders to start fresh
//clean: {
// dist: {
// files: [{
// dot: true,
// src: [
// '.tmp',
// '<%= yeoman.dist %>/{,**/}*',
// '!<%= yeoman.dist %>/.git{,**/}*'
// ]
// }]
// },
// server: '.tmp',
// tenant: '<%= yeoman.whiteLabelApp %>'
//},
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
html: 'dist/three-d-viewer.html',
options: {
dest: 'dist',
flow: {
html: {
steps: {
js: ['concat', 'uglifyjs']
},
post: {}
}
}
}
},
// Performs rewrites based on filerev and the useminPrepare configuration
usemin: {
html: 'dist/*.html',
options: {
assetsDirs: [
//'<%= yeoman.dist %>',
//'<%= yeoman.dist %>/images',
//'<%= yeoman.dist %>/styles'
]
//patterns: {
// html: [
// [
// ///mkp-*[^\>]*[^\>\S]+custom-src-attribute-here=['"]([^'"\)#]+)(#.+)?["']/gm
// /mkp-[^\>]*[^\>]+svg-icon=['"]([^'"\)#]+)(#.+)?["']/gm,
// 'mkp-directives'
// ]
// ]
//}
}
},
uglify: {
options: {
sourceMap: true,
mangle: false
}
},
htmlmin: {
dist: {
options: {
collapseWhitespace: true,
conservativeCollapse: true,
collapseBooleanAttributes: false,
removeCommentsFromCDATA: true,
removeOptionalTags: true
},
files: [{
expand: true,
cwd: '',
src: '*.html',
dest: 'dist/'
}]
}
},
vulcanize: {
default: {
files: {
'dist/three-d-viewer.html': 'three-d-viewer.html'
}
}
},
// Empties folders to start fresh
clean: {
dist: {
src: ["dist/**/*", 'bower_components/3DViewerComponent/**/*']
}
},
//clean: ["dist"],
//inline: {
// dist: {
// options:{
// tag: 'js/'
// },
// src: 'three-d-viewer.html',
// dest: 'dist/three-d-viewer.html'
// }
//},
babel: {
options: {
sourceMap: true,
presets: ['es2015']
},
files: {
expand: true,
cwd: '',
ext: '-es5.js',
src: ['*.es6.js'],
dest: ''
}
},
inline: {
dist: {
options:{
tag: ''
},
src: 'three-d-viewer.html',
dest: 'dist/three-d-viewer.html'
},
test: {
options:{
tag: ''
},
src: 'three-d-viewer.html',
dest: 'bower_components/3DViewerComponent/dist/three-d-viewer.html'
}
},
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '',
dest: 'bower_components/3DViewerComponent',
src: [
'js/*'
]
}]
}
},
watch: {
js: {
files: ['**/*.js'],
tasks: ['clean:dist','copy','babel','inline:dist','inline:test','useminPrepare','uglify','usemin'],
options: {
livereload: true
}
},
html: {
files: ['*.html'],
tasks: ['clean:dist','copy','babel','inline:dist','inline:test','useminPrepare','uglify','usemin'],
options: {
livereload: true
}
}
},
connect: {
livereload: {
options:{
port: 9001,
hostname: "0.0.0.0",
// Prevents Grunt to close just after the task (starting the server) completes
// This will be removed later as `watch` will take care of that
//keepalive: true,
open: {
all: {
// Gets the port from the connect configuration
path: 'http://localhost:<%= connect.livereload.options.port%>'
}
}
}
}
}
});
grunt.loadNpmTasks('grunt-vulcanize');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('build', 'Build the app', function () {
grunt.task.run([
'clean:dist',
'copy',
'babel',
'inline:test',
'inline:dist',
'useminPrepare',
//'concat',
//'vulcanize',
//'inline',
'uglify',
'usemin',
'connect:livereload',
'watch'
]);
});
};