diff --git a/js/webpack/app.js b/js/webpack/app.js index e849ad825..ba8e9a765 100644 --- a/js/webpack/app.js +++ b/js/webpack/app.js @@ -25,6 +25,8 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin'); const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin'); +const rulesEs6 = require('./rules/es6'); +const rulesParity = require('./rules/parity'); const Shared = require('./shared'); const DAPPS = require('../src/views/Dapps/builtin.json'); @@ -60,22 +62,13 @@ module.exports = { module: { rules: [ + rulesParity, + rulesEs6, { test: /\.js$/, exclude: /(node_modules)/, use: [ 'happypack/loader?id=babel-js' ] }, - // duplicated for clarity since the number of @parity modules will increase - { - test: /\.js$/, - include: /node_modules\/@parity\/(abi|api|jsonrpc|wordlist)/, - use: 'babel-loader' - }, - { - test: /\.js$/, - include: /node_modules\/(material-chip-input|ethereumjs-tx)/, - use: 'babel-loader' - }, { test: /\.json$/, use: [ 'json-loader' ] diff --git a/js/webpack/libraries.js b/js/webpack/libraries.js index 0c151b828..d9ddaf53c 100644 --- a/js/webpack/libraries.js +++ b/js/webpack/libraries.js @@ -18,6 +18,8 @@ const path = require('path'); +const rulesEs6 = require('./rules/es6'); +const rulesParity = require('./rules/parity'); const Shared = require('./shared'); const DEST = process.env.BUILD_DEST || '.build'; @@ -49,6 +51,8 @@ module.exports = { module: { rules: [ + rulesParity, + rulesEs6, { test: /\.js$/, exclude: /node_modules/, @@ -58,17 +62,6 @@ module.exports = { 'babel-loader?cacheDirectory=true' ] }, - // duplicated for clarity since the number of @parity modules will increase - { - test: /\.js$/, - include: /node_modules\/@parity\/(abi|api|jsonrpc|wordlist)/, - use: 'babel-loader' - }, - { - test: /\.js$/, - include: /node_modules\/ethereumjs-tx/, - use: 'babel-loader' - }, { test: /\.json$/, use: [ 'json-loader' ] diff --git a/js/webpack/npm.js b/js/webpack/npm.js index 2230bf90f..94d8cdc1e 100644 --- a/js/webpack/npm.js +++ b/js/webpack/npm.js @@ -18,6 +18,8 @@ const path = require('path'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const packageJson = require('../package.json'); +const rulesEs6 = require('./rules/es6'); +const rulesParity = require('./rules/parity'); const Shared = require('./shared'); const ENV = process.env.NODE_ENV || 'development'; @@ -26,6 +28,7 @@ const isProd = ENV === 'production'; const LIBRARY = process.env.LIBRARY; if (!LIBRARY) { + console.error('$LIBRARY environment variable not defined'); process.exit(-1); } @@ -57,6 +60,8 @@ module.exports = { /babel-polyfill/ ], rules: [ + rulesParity, + rulesEs6, { test: /(\.jsx|\.js)$/, // use: [ 'happypack/loader?id=js' ], @@ -65,11 +70,6 @@ module.exports = { 'babel-loader?cacheDirectory=true' ], exclude: /node_modules/ - }, - { - test: /\.js$/, - include: /node_modules\/(ethereumjs-tx|@parity\/wordlist)/, - use: 'babel-loader' } ] }, diff --git a/js/webpack/rules/es6.js b/js/webpack/rules/es6.js new file mode 100644 index 000000000..8e485424e --- /dev/null +++ b/js/webpack/rules/es6.js @@ -0,0 +1,21 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +module.exports = { + test: /\.js$/, + include: /node_modules\/(material-chip-input|ethereumjs-tx)/, + use: 'babel-loader' +}; diff --git a/js/webpack/rules/parity.js b/js/webpack/rules/parity.js new file mode 100644 index 000000000..6897b218e --- /dev/null +++ b/js/webpack/rules/parity.js @@ -0,0 +1,21 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +module.exports = { + test: /\.js$/, + include: /node_modules\/@parity\/(abi|api|jsonrpc|wordlist)/, + use: 'babel-loader' +};