@@ -6,6 +6,7 @@ module.exports = function(grunt) {
6
6
grunt . loadNpmTasks ( 'grunt-terser' ) ;
7
7
grunt . loadNpmTasks ( 'grunt-contrib-jasmine' ) ;
8
8
grunt . loadNpmTasks ( 'grunt-contrib-copy' ) ;
9
+ grunt . loadNpmTasks ( 'grunt-exorcise' ) ;
9
10
10
11
grunt . initConfig ( {
11
12
babel : {
@@ -22,57 +23,91 @@ module.exports = function(grunt) {
22
23
} ,
23
24
] ,
24
25
} ,
25
- bundle : {
26
- files : [
27
- {
28
- cwd : './build' ,
29
- expand : true ,
30
- src : [ 'exceljs.bare.js' , 'exceljs.js' ] ,
31
- dest : './dist/' ,
32
- } ,
33
- ] ,
34
- } ,
35
26
} ,
36
27
browserify : {
37
- bare : {
38
- src : [ './build/lib/exceljs.bare.js' ] ,
39
- dest : './build/exceljs.bare.js' ,
40
- options : {
41
- browserifyOptions : {
42
- standalone : 'ExcelJS' ,
43
- } ,
28
+ options : {
29
+ transform : [
30
+ [ 'babelify' , {
31
+ // enable babel transpile for node_modules
32
+ global : true ,
33
+ presets : [ '@babel/preset-env' ] ,
34
+ // core-js should not be transpiled
35
+ // See https://github.com/zloirock/core-js/issues/514
36
+ ignore : [ / n o d e _ m o d u l e s [ \\ / ] c o r e - j s / ] ,
37
+ } ] ,
38
+ ] ,
39
+ browserifyOptions : {
40
+ // enable source map for browserify
41
+ debug : true ,
42
+ standalone : 'ExcelJS' ,
44
43
} ,
45
44
} ,
45
+ bare : {
46
+ // keep the original source for source maps
47
+ src : [ './lib/exceljs.bare.js' ] ,
48
+ dest : './dist/exceljs.bare.js' ,
49
+ } ,
46
50
bundle : {
47
- src : [ './build/lib/exceljs.browser.js' ] ,
48
- dest : './build/exceljs.js' ,
49
- options : {
50
- browserifyOptions : {
51
- standalone : 'ExcelJS' ,
52
- } ,
53
- } ,
51
+ // keep the original source for source maps
52
+ src : [ './lib/exceljs.browser.js' ] ,
53
+ dest : './dist/exceljs.js' ,
54
54
} ,
55
55
spec : {
56
+ options : {
57
+ transform : null ,
58
+ browserifyOptions : null ,
59
+ } ,
56
60
src : [ './build/spec/browser/exceljs.spec.js' ] ,
57
61
dest : './build/web/exceljs.spec.js' ,
58
62
} ,
59
63
} ,
64
+
60
65
terser : {
61
66
options : {
62
- sourceMap : true ,
63
67
output : {
64
68
preamble : '/*! ExcelJS <%= grunt.template.today("dd-mm-yyyy") %> */\n' ,
65
69
ascii_only : true ,
66
70
} ,
67
71
} ,
68
72
dist : {
73
+ options : {
74
+ // Keep the original source maps from browserify
75
+ // See also https://www.npmjs.com/package/terser#source-map-options
76
+ sourceMap : {
77
+ content : 'inline' ,
78
+ url : 'exceljs.min.js.map' ,
79
+ } ,
80
+ } ,
69
81
files : {
70
82
'./dist/exceljs.min.js' : [ './dist/exceljs.js' ] ,
83
+ } ,
84
+ } ,
85
+ bare : {
86
+ options : {
87
+ // Keep the original source maps from browserify
88
+ // See also https://www.npmjs.com/package/terser#source-map-options
89
+ sourceMap : {
90
+ content : 'inline' ,
91
+ url : 'exceljs.bare.min.js.map' ,
92
+ } ,
93
+ } ,
94
+ files : {
71
95
'./dist/exceljs.bare.min.js' : [ './dist/exceljs.bare.js' ] ,
72
96
} ,
73
97
} ,
74
98
} ,
75
99
100
+ // Move source maps to a separate file
101
+ exorcise : {
102
+ bundle : {
103
+ options : { } ,
104
+ files : {
105
+ './dist/exceljs.js.map' : [ './dist/exceljs.js' ] ,
106
+ './dist/exceljs.bare.js.map' : [ './dist/exceljs.bare.js' ] ,
107
+ } ,
108
+ } ,
109
+ } ,
110
+
76
111
copy : {
77
112
dist : {
78
113
files : [
@@ -93,6 +128,6 @@ module.exports = function(grunt) {
93
128
} ,
94
129
} ) ;
95
130
96
- grunt . registerTask ( 'build' , [ 'babel:dist' , 'browserify' , 'babel:bundle ' , 'terser ' , 'copy' ] ) ;
131
+ grunt . registerTask ( 'build' , [ 'babel:dist' , 'browserify' , 'terser ' , 'exorcise ' , 'copy' ] ) ;
97
132
grunt . registerTask ( 'ug' , [ 'terser' ] ) ;
98
133
} ;
0 commit comments