Skip to content

Commit 21a4c30

Browse files
committed
Add babel for ES6 support
(cherry picked from commit e58bd66)
1 parent bb071c3 commit 21a4c30

6 files changed

Lines changed: 13274 additions & 132 deletions

File tree

Gruntfile.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ module.exports = function(grunt) {
108108
name: 'core/app',
109109
mainConfigFile: "frontend/src/core/config.js",
110110
out: "frontend/build/js/origin.js",
111-
generateSourceMaps: true,
112111
preserveLicenseComments: true,
113112
optimize: "none"
114113
}
@@ -119,10 +118,32 @@ module.exports = function(grunt) {
119118
name: 'core/app',
120119
mainConfigFile: "frontend/src/core/config.js",
121120
out: "frontend/build/js/origin.js",
122-
optimize: "uglify2"
121+
optimize: "none"
123122
}
124123
}
125124
},
125+
babel: {
126+
dev: {
127+
options: {
128+
compact: false,
129+
retainLines: true,
130+
presets: [ [ '@babel/preset-env', { targets: { ie: '11' } } ] ],
131+
sourceType: 'script'
132+
},
133+
src: 'frontend/build/js/origin.js',
134+
dest: 'frontend/build/js/origin.js'
135+
},
136+
compile: {
137+
options: {
138+
comments: false,
139+
minified: true,
140+
presets: [ [ '@babel/preset-env', { targets: { ie: '11' } } ] ],
141+
sourceType: 'script'
142+
},
143+
src: 'frontend/build/js/origin.js',
144+
dest: 'frontend/build/js/origin.js'
145+
}
146+
},
126147
mochaTest: {
127148
src: ['test/*.js'],
128149
options: {
@@ -315,10 +336,10 @@ module.exports = function(grunt) {
315336
config.isProduction = isProduction;
316337
grunt.file.write(configFile, JSON.stringify(config, null, 2));
317338
// run the task
318-
grunt.task.run(['migration-conf', 'requireBundle', 'generate-lang-json', 'copy', 'less:' + compilation, 'handlebars', 'requirejs:'+ compilation]);
339+
grunt.task.run(['migration-conf', 'requireBundle', 'generate-lang-json', 'copy', 'less:' + compilation, 'handlebars', 'requirejs:'+ compilation, `babel:${compilation}`]);
319340

320341
} catch(e) {
321-
grunt.task.run(['requireBundle', 'copy', 'less:' + compilation, 'handlebars', 'requirejs:' + compilation]);
342+
grunt.task.run(['requireBundle', 'copy', 'less:' + compilation, 'handlebars', 'requirejs:' + compilation, `babel:${compilation}`]);
322343
}
323344
});
324345
};

frontend/src/core/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'jqueryForm',
1212
'jqueryTagsInput',
1313
'jqueryUI',
14+
'polyfill',
1415
'scrollTo',
1516
'selectize',
1617
'sweetalert',

frontend/src/core/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require.config({
1515
modernizr: 'libraries/modernizr',
1616
moment: 'libraries/moment.min',
1717
pikaday: 'libraries/pikaday/js/pikaday',
18+
polyfill: 'libraries/polyfill.min',
1819
polyglot: 'libraries/polyglot.min',
1920
scrollTo: 'libraries/scrollTo',
2021
selectize: 'libraries/selectize/js/selectize',

frontend/src/libraries/polyfill.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)