-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
95 lines (79 loc) · 1.99 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
/* eslint-disable no-unused-vars */
var grunt = require('grunt');
var babel = require('rollup-plugin-babel');
var uglify = require('rollup-plugin-uglify');
module.exports = function () {
var config = {
pkg: grunt.file.readJSON('package.json')
};
/* -------------------------------------------- */
/* rollup */
config.rollup = {
dist: {
options: {
format: 'iife',
sourceMap: true,
sourceMapFile: 'src/mumpitz.js',
useStrict: true,
plugins: function () {
var arr = [];
arr.push(babel({
exclude: 'node_modules/**'
}));
return arr;
}
},
files: [{
dest: 'dist/mumpitz.js',
src: 'src/mumpitz.js'
}]
}
};
/* -------------------------------------------- */
/* uglify */
config.uglify = {
dist: {
options: {
mangle: false,
sourceMap: true
},
files: {
'dist/mumpitz.min.js': ['dist/mumpitz.js']
}
}
};
/* -------------------------------------------- */
/* compress */
config.compress = {
dist: {
options: {
mode: 'gzip'
},
expand: true,
cwd: 'dist',
src: [ '*.min.js' ],
dest: 'dist',
ext: '.min.js.gz'
}
};
/* -------------------------------------------- */
/* watch */
config.watch = {
scripts: {
files: 'src/*.js',
tasks: ['build-js'],
options: {
interrupt: true
}
}
};
/* -------------------------------------------- */
grunt.initConfig(config);
/* -------------------------------------------- */
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-rollup');
grunt.registerTask('dist', ['rollup', 'uglify', 'compress']);
grunt.registerTask('default', ['dist']);
};