-
Notifications
You must be signed in to change notification settings - Fork 20
/
Gruntfile.js
139 lines (130 loc) · 4.69 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
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
dist: {
files: {
'tmp/viki.transpiled.min.js': ['tmp/viki.transpiled.js']
}
}
},
concat: {
options: {
// define a string to put between each file in the concatenated output
separator: ';\n',
},
dist: {
// the files to concatenate
src: ['tmp/libs/**/*.js', 'tmp/viki.transpiled.js'],
// the location of the resulting JS file
dest: 'dist/js/<%= pkg.name %>.js'
},
release: {
// the files to concatenate
src: ['tmp/libs/**/*.js', 'tmp/viki.transpiled.min.js'],
// the location of the resulting JS file
dest: 'dist/js/<%= pkg.name %>.js'
}
},
jshint: {
// define the files to lint
files: ['Gruntfile.js', 'js/**/*.js'],
// configure JSHint (documented at http://www.jshint.com/docs/)
options: {
// more options here if you want to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
},
esversion: 6
}
},
watch: {
files: ['<%= jshint.files %>', 'viki.html', 'css/*'],
tasks: ['default']
},
babel: {
options: {
sourceMap: false,
presets: [
[
'@babel/preset-env',
{
"targets": {
"chrome": "58",
"ie": "11"
}
}
]
]
},
dist: {
files: [{
expand: true,
cwd: 'tmp/',
src: ['*.js'],
dest: 'tmp/'
}]
}
},
browserify: {
dist: {
files: {
// destination for transpiled js : source js
'tmp/viki.transpiled.js': 'tmp/*.js'
},
options: {
transform: [['babelify', { presets: ['@babel/preset-env']}]],
}
},
libs: {
files: {
// destination for transpiled js : source js
'tmp/libs/markdown-it/markdown-it-texmath.js': 'tmp/libs/markdown-it/markdown-it-texmath.js'
},
options: {
transform: [['babelify', { presets: ['@babel/preset-env']}]],
}
}
},
copy: {
pre: {
files: [
{ expand: true, cwd: 'js', src: '**', dest: 'tmp/'},
{ expand: true, src: 'libs/**/*.js', dest: 'tmp/'},
],
},
post: {
files: [
{ expand: true, src: 'viki.html', dest: 'dist/', rename: function(dest, src) {
return dest + 'index.html';
}},
{ expand: true, src: 'js/custom.js', dest: 'dist/'},
{ expand: true, src: 'css/*', dest: 'dist/'},
],
},
},
clean: {
options: {
force: true,
},
tmp: ['tmp/'],
},
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-browserify');
// the default task can be run just by typing "grunt" on the command line
grunt.registerTask('default', ['jshint', 'copy:pre', 'browserify:dist', 'concat:dist', 'copy:post', 'clean:tmp']);
grunt.registerTask('release', ['jshint', 'copy:pre', 'browserify:dist', 'uglify', 'concat:release', 'copy:post', 'clean:tmp']);
grunt.registerTask('watcher', ['watch']);
};