/
Gruntfile.js
148 lines (135 loc) · 3.67 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
'use strict'
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// copy
copy: {
main: {
expand: true,
cwd: './src',
src: ['./**', '!./offline/**', '!./data/**'],
dest: './build'
}
},
// concat
concat: {
js: {
src: [
// in this order...
'./build/js/SoundTouch-merged.js',
'./build/js/wavesurfer.js',
'./build/js/wavesurfer-regions.js',
'./build/js/jquerymods.js',
'./build/js/dropZone.js',
'./build/js/main.js'
],
dest: './build/js/concat.js'
},
css: {
src: './build/css/*.css',
dest: './build/css/concat.css'
}
},
// clean
clean: {
folder: ['./build']
// dist2: {
// contents : ['build/js/*.js', '!build/js/*.min.js']
// }
},
'string-replace': {
dist: {
files: [
{
expand: true,
cwd: './build',
src: '*.html',
dest: './build'
}
],
options: {
replacements: [
{
pattern: '<script src="offline/jquery-3.1.1.js"></script>',
replacement:
'<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>'
},
{
pattern: '<script src="offline/bootstrap-3.3.7.js"></script>',
replacement:
'<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>'
},
{
pattern: '<link rel="stylesheet" type="text/css" href="offline/bootstrap-3.3.7.css">',
replacement:
'<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">'
},
// get concat js files
{
pattern:
'<script src="js/SoundTouch-merged.js"></script><script src="js/wavesurfer.js"></script><script src="js/wavesurfer-regions.js"></script><script src="js/jquerymods.js"></script><script src="js/dropZone.js"></script><script src="js/main.js"></script>',
replacement: '<script src="js/concat.min.js"></script>'
},
// get concat css files
{
pattern: '<link rel="stylesheet" type="text/css" href="css/myCss.css">',
replacement: '<link rel="stylesheet" type="text/css" href="css/concat.css">'
}
]
}
}
},
uglify: {
development: {
files: [
{
// expand: true,
// cwd: './build/',
src: 'build/js/concat.js',
dest: 'build/js/concat.min.js'
}
]
},
options: {}
},
babel: {
options: {
sourceMap: false,
presets: ['es2015']
},
build: {
expand: true,
src: 'build/js/concat.js',
dest: ''
}
},
htmlmin: {
dev: {
options: {
removeRedundantAttributes: true,
removeComments: true,
removeOptionalTags: true,
collapseWhitespace: true
},
files: [
{
expand: true,
src: './build/*.html',
dest: ''
}
]
}
}
})
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-string-replace')
grunt.loadNpmTasks('grunt-babel')
grunt.loadNpmTasks('grunt-contrib-htmlmin')
grunt.registerTask('build', ['clean', 'copy', 'string-replace', 'concat', 'babel', 'uglify', 'htmlmin']) // old
// grunt.registerTask('build', ['clean:dist1', 'clean:dist2']);
}