I am writing ES6 JavaScript modules and using Babel to translate them to ES5. Babel generates source codes that point to the source code for ES6. Then I use r.js to take these AMD ES5 modules and combine and remove them. r.js creates a source map that shows ES5 files. I want ES6 from the first step. My grunt file is as follows:
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
babel: {
options: {
modules: "amd",
sourceMap: true
},
dist: {
files: {
"es5/editor.js": "src/editor.js",
"es5/editor-events.js": "src/editor-events.js"
}
}
},
requirejs: {
production: {
options: {
baseUrl: "es5",
mainConfigFile: "es5/require.config.js",
name: "../node_modules/almond/almond",
include: ["editor"],
out: "dist/ed.js",
optimize: "uglify2",
generateSourceMaps: true,
preserveLicenseComments: false
}
}
}
});
grunt.registerTask('default', ['babel', 'requirejs']);
};
It compiles everything perfectly. But it loses good ES6 source codes. Any way to save them? Is there a better build process that leads me to a single, JavaScript browser file?
source
share