rev webpack config w.r.t. webpack 4, babel 7

This commit is contained in:
Michael Bradley, Jr 2018-07-19 20:52:18 -05:00
parent 5f7fd7107f
commit 5a5fe476e2
1 changed files with 35 additions and 5 deletions

View File

@ -36,13 +36,20 @@ class WebpackProcess extends ProcessWrapper {
}
webpackRun(filename, options, includeModules, importsList, detectErrors, realCwd, callback) {
const self = this;
let defaultOptions = {
mode: self.env === 'development' ? 'none' : 'production',
entry: fs.dappPath(filename),
output: {
globalObject: 'typeof self !== \'undefined\' ? self : this',
libraryExport: 'default',
libraryTarget: 'umd',
path: fs.dappPath('.embark'),
filename: filename
filename: filename,
umdNamedDefine: true
},
profile: true,
stats: 'verbose',
resolve: {
alias: importsList,
modules: [
@ -86,17 +93,40 @@ class WebpackProcess extends ProcessWrapper {
loader: "babel-loader",
exclude: /(node_modules|bower_components)/,
options: {
extends: path.join(realCwd, '.babelrc'),
presets: ['babel-preset-es2016', 'babel-preset-es2017', 'babel-preset-react'].map(require.resolve),
plugins: ["babel-plugin-webpack-aliases"].map(require.resolve),
presets: [
[
"@babel/preset-env", {
modules: false,
targets: {
browsers: ["last 1 version", "not dead", "> 0.2%"]
}
}
],
"@babel/preset-react"
].map(pkg => {
if (Array.isArray(pkg)) {
let _pkg = pkg[0];
pkg[0] = require.resolve(_pkg);
return pkg;
} else {
return require.resolve(pkg);
}
}),
plugins: [
"@babel/plugin-transform-runtime",
"babel-plugin-webpack-aliases"
].map(require.resolve),
compact: false
}
}
]
};
}
let dappBabelrc = path.join(realCwd, '.babelrc');
if (fs.existsSync(dappBabelrc)) {
webpackOptions.module.rules[3].options.extends = dappBabelrc;
}
}
webpack(webpackOptions).run((err, stats) => {
async.waterfall([