2016-12-10 15:24:01 +00:00
|
|
|
var babel = require("babel-core");
|
2017-01-15 17:19:53 +00:00
|
|
|
require("babel-preset-react");
|
|
|
|
require("babel-preset-es2015");
|
|
|
|
require("babel-preset-es2016");
|
|
|
|
require("babel-preset-es2017");
|
2016-12-10 15:24:01 +00:00
|
|
|
|
|
|
|
module.exports = function(embark) {
|
|
|
|
|
2017-01-15 18:53:35 +00:00
|
|
|
embark.registerPipeline((embark.pluginConfig.files || ['*.js', '*.jsx']), function(opts) {
|
2016-12-10 15:24:01 +00:00
|
|
|
var targetFile = opts.targetFile;
|
|
|
|
var source = opts.source;
|
2017-01-15 18:49:45 +00:00
|
|
|
var presets = embark.pluginConfig.presets || ['es2015', 'es2016', 'es2017', 'react'];
|
|
|
|
var minified = (embark.pluginConfig.minified !== undefined ? embark.pluginConfig.minified : true);
|
2016-12-10 15:24:01 +00:00
|
|
|
|
2017-01-15 18:49:45 +00:00
|
|
|
return babel.transform(source, {minified: minified, presets: presets}).code;
|
2016-12-10 15:24:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
};
|