Cleanup webpack config

This commit is contained in:
Jaco Greeff 2017-08-02 08:44:56 +02:00
parent aa95c09a88
commit cbd32035c8
2 changed files with 6 additions and 59 deletions

View File

@ -15,13 +15,13 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
const HappyPack = require('happypack');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const PackageJson = require('../package.json');
const EMBED = process.env.EMBED;
const ENV = process.env.NODE_ENV || 'development';
const isProd = ENV === 'production';
const UI_VERSION = PackageJson
.version
.split('.')
@ -33,43 +33,6 @@ const UI_VERSION = PackageJson
return `${parseInt(part, 10) + 1}`;
})
.join('.');
const EMBED = process.env.EMBED;
const ENV = process.env.NODE_ENV || 'development';
const isProd = ENV === 'production';
function getBabelrc () {
const babelrc = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../.babelrc')));
const es2015Index = babelrc.presets.findIndex((p) => p === 'es2015');
// [ "es2015", { "modules": false } ]
babelrc.presets[es2015Index] = [ 'es2015', { modules: false } ];
babelrc['babelrc'] = false;
const BABEL_PRESET_ENV = process.env.BABEL_PRESET_ENV;
const npmStart = process.env.npm_lifecycle_event === 'start';
const npmStartApp = process.env.npm_lifecycle_event === 'start:app';
if (BABEL_PRESET_ENV && (npmStart || npmStartApp)) {
console.log('using babel-preset-env');
babelrc.presets = [
// 'es2017',
'stage-0', 'react',
[
'env',
{
targets: { browsers: ['last 2 Chrome versions'] },
modules: false,
loose: true,
useBuiltIns: true
}
]
];
}
return babelrc;
}
function getPlugins (_isProd = isProd) {
const plugins = [
@ -93,13 +56,6 @@ function getPlugins (_isProd = isProd) {
if (_isProd) {
plugins.push(
new webpack.optimize.OccurrenceOrderPlugin(!_isProd),
new CircularDependencyPlugin({
exclude: /node_modules/,
failOnError: true
}),
new webpack.optimize.UglifyJsPlugin({
screwIe8: true,
compress: {
@ -147,7 +103,6 @@ function addProxies (app) {
}
module.exports = {
getBabelrc: getBabelrc,
getPlugins: getPlugins,
addProxies: addProxies
getPlugins,
addProxies
};

View File

@ -20,15 +20,7 @@ module.exports = {
context: path.join(__dirname, '../src'),
resolve: {
alias: {
'~': path.resolve(__dirname, '..'),
'@parity/abi': path.resolve(__dirname, '../node_modules/@parity/abi'),
'@parity/api': path.resolve(__dirname, '../node_modules/@parity/api'),
'@parity/etherscan': path.resolve(__dirname, '../node_modules/@parity/etherscan'),
'@parity/jsonrpc': path.resolve(__dirname, '../node_modules/@parity/jsonrpc'),
'@parity/shared': path.resolve(__dirname, '../node_modules/@parity/shared'),
'@parity/ui': path.resolve(__dirname, '../node_modules/@parity/ui'),
'@parity/wordlist': path.resolve(__dirname, '../node_modules/@parity/wordlist'),
'@parity': path.resolve(__dirname, '../packages')
'~': path.resolve(__dirname, '..')
}
}
};