-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
129 lines (119 loc) · 2.56 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
var babel = require('rollup-plugin-babel');
var uglify = require('rollup-plugin-uglify');
var replace = require('rollup-plugin-replace');
module.exports = function(grunt)
{
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
rollup: {
cjs: {
options: {
format: 'cjs',
moduleName: 'kff',
moduleId: 'kff',
exports: 'named',
banner: grunt.file.read('./src/banner.js'),
plugins: [
// babel({
// exclude: './node_modules/**'
// })
]
},
files: {
'./dist/kff-cjs.js': './src/entry-es.js'
},
},
es: {
options: {
format: 'es',
moduleName: 'kff',
moduleId: 'kff',
banner: grunt.file.read('./src/banner.js'),
plugins: [
// babel({
// exclude: './node_modules/**'
// })
]
},
files: {
'./dist/kff-es.js': './src/entry-es.js'
},
},
umd: {
options: {
format: 'umd',
moduleName: 'kff',
moduleId: 'kff',
banner: grunt.file.read('./src/banner.js'),
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production')
}),
// babel({
// exclude: './node_modules/**'
// }),
]
},
files: {
'./dist/kff.js': './src/entry-umd.js'
},
},
min: {
options: {
format: 'umd',
moduleName: 'kff',
moduleId: 'kff',
banner: grunt.file.read('./src/banner.js'),
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production')
}),
// babel({
// exclude: './node_modules/**'
// }),
uglify({
output: {
comments: (node, comment) => comment.type === 'comment2' ? comment.value.indexOf('License') !== -1 : undefined
}
})
]
},
files: {
'./dist/kff.min.js': './src/entry-umd.js'
},
}
},
jshint: {
all: './src/**/*.js',
options: {
smarttabs: false
}
},
karma: {
unit: {
configFile: 'karma.conf.js',
client: {
mocha: {
timeout: 5000
}
}
}
},
shell: {
options: {
stderr: true
},
rollup: {
command: '"./node_modules/.bin/rollup" -c rollup-watch-config.js -o ./dist/kff-es.js -w'
}
}
});
grunt.loadNpmTasks('grunt-rollup');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-karma');
grunt.registerTask('build', ['rollup']);
grunt.registerTask('test', ['build', 'karma']);
grunt.registerTask('default', ['build']);
grunt.registerTask('w', ['shell:rollup']);
};