diff --git a/js/src/views/Status/components/RpcNav/RpcNav.js b/js/src/views/Status/components/RpcNav/RpcNav.js
index 690f4355e..b4cf2a6ef 100644
--- a/js/src/views/Status/components/RpcNav/RpcNav.js
+++ b/js/src/views/Status/components/RpcNav/RpcNav.js
@@ -24,10 +24,10 @@ export default class RpcNav extends Component {
return (
-
+
-
+
);
diff --git a/js/src/views/WriteContract/writeContract.js b/js/src/views/WriteContract/writeContract.js
index bb9c966f9..9598c4d43 100644
--- a/js/src/views/WriteContract/writeContract.js
+++ b/js/src/views/WriteContract/writeContract.js
@@ -118,8 +118,7 @@ class WriteContract extends Component {
-
+ />
.
-
-const HappyPack = require('happypack');
-const path = require('path');
-const postcssImport = require('postcss-import');
-const postcssNested = require('postcss-nested');
-const postcssVars = require('postcss-simple-vars');
-const rucksack = require('rucksack-css');
-const webpack = require('webpack');
-const WebpackErrorNotificationPlugin = require('webpack-error-notification');
-const CopyWebpackPlugin = require('copy-webpack-plugin');
-
-const ENV = process.env.NODE_ENV || 'development';
-const isProd = ENV === 'production';
-const DEST = process.env.BUILD_DEST || '.build';
-
-module.exports = {
- debug: !isProd,
- cache: !isProd,
- devtool: isProd ? '#eval' : '#cheap-module-eval-source-map',
- context: path.join(__dirname, './src'),
- entry: {
- // dapps
- 'basiccoin': ['./dapps/basiccoin.js'],
- 'dappreg': ['./dapps/dappreg.js'],
- 'githubhint': ['./dapps/githubhint.js'],
- 'registry': ['./dapps/registry.js'],
- 'signaturereg': ['./dapps/signaturereg.js'],
- 'localtx': ['./dapps/localtx.js'],
- 'tokenreg': ['./dapps/tokenreg.js'],
- // app
- 'index': ['./index.js']
- },
- output: {
- path: path.join(__dirname, DEST),
- filename: '[name].js'
- },
- module: {
- loaders: [
- {
- test: /\.js$/,
- exclude: /node_modules/,
- loaders: [ 'happypack/loader?id=js' ]
- },
- {
- test: /\.js$/,
- include: /node_modules\/material-ui-chip-input/,
- loader: 'babel'
- },
- {
- test: /\.json$/,
- loaders: ['json']
- },
- {
- test: /\.html$/,
- loader: 'file?name=[name].[ext]!extract-loader!html-loader'
- },
-
- {
- test: /\.css$/,
- include: [/src/],
- loaders: [ 'happypack/loader?id=css' ]
- },
- {
- test: /\.css$/,
- exclude: [/src/],
- loader: 'style!css'
- },
- {
- test: /\.(png|jpg)$/,
- loader: 'file-loader?name=[name].[hash].[ext]'
- },
- {
- test: /\.(woff(2)|ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
- loader: 'file-loader'
- }
- ],
- noParse: [
- /node_modules\/sinon/
- ]
- },
- resolve: {
- root: path.join(__dirname, 'node_modules'),
- fallback: path.join(__dirname, 'node_modules'),
- extensions: ['', '.js', '.jsx'],
- unsafeCache: true
- },
- resolveLoaders: {
- root: path.join(__dirname, 'node_modules'),
- fallback: path.join(__dirname, 'node_modules')
- },
-
- htmlLoader: {
- root: path.resolve(__dirname, 'assets/images'),
- attrs: ['img:src', 'link:href']
- },
-
- postcss: [
- postcssImport({
- addDependencyTo: webpack
- }),
- postcssNested({}),
- postcssVars({
- unknown: function (node, name, result) {
- node.warn(result, `Unknown variable ${name}`);
- }
- }),
- rucksack({
- autoprefixer: true
- })
- ],
- plugins: (function () {
- const plugins = [
- new HappyPack({
- id: 'css',
- threads: 4,
- loaders: [
- 'style',
- 'css?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
- 'postcss'
- ]
- }),
- new HappyPack({
- id: 'js',
- threads: 4,
- loaders: isProd ? ['babel'] : [
- 'react-hot',
- 'babel?cacheDirectory=true'
- ]
- }),
- new CopyWebpackPlugin([{ from: './error_pages.css', to: 'styles.css' }], {}),
- new WebpackErrorNotificationPlugin(),
- new webpack.DefinePlugin({
- 'process.env': {
- NODE_ENV: JSON.stringify(ENV),
- RPC_ADDRESS: JSON.stringify(process.env.RPC_ADDRESS),
- PARITY_URL: JSON.stringify(process.env.PARITY_URL),
- LOGGING: JSON.stringify(!isProd)
- }
- }),
-
- new webpack.DllReferencePlugin({
- context: '.',
- manifest: require(`./${DEST}/vendor-manifest.json`)
- })
- ];
-
- if (!isProd) {
- plugins.push(
- new webpack.optimize.CommonsChunkPlugin({
- filename: 'commons.js',
- name: 'commons'
- })
- );
- }
-
- if (isProd) {
- plugins.push(
- new webpack.optimize.CommonsChunkPlugin({
- chunks: ['index'],
- name: 'commons'
- })
- );
-
- plugins.push(new webpack.optimize.OccurrenceOrderPlugin(false));
- plugins.push(new webpack.optimize.DedupePlugin());
- plugins.push(new webpack.optimize.UglifyJsPlugin({
- screwIe8: true,
- compress: {
- warnings: false
- },
- output: {
- comments: false
- }
- }));
- }
-
- return plugins;
- }()),
- devServer: {
- contentBase: `./${DEST}`,
- historyApiFallback: false,
- quiet: false,
- hot: !isProd,
- proxy: [
- {
- context: (pathname, req) => {
- return pathname === '/' && req.method === 'HEAD';
- },
- target: 'http://127.0.0.1:8180',
- changeOrigin: true,
- autoRewrite: true
- },
- {
- context: '/api',
- target: 'http://127.0.0.1:8080',
- changeOrigin: true,
- autoRewrite: true
- },
- {
- context: '/app',
- target: 'http://127.0.0.1:8080',
- changeOrigin: true,
- pathRewrite: {
- '^/app': ''
- }
- },
- {
- context: '/parity-utils',
- target: 'http://127.0.0.1:3000',
- changeOrigin: true,
- pathRewrite: {
- '^/parity-utils': ''
- }
- },
- {
- context: '/rpc',
- target: 'http://127.0.0.1:8080',
- changeOrigin: true
- }
- ]
- }
-};
diff --git a/js/webpack/app.js b/js/webpack/app.js
new file mode 100644
index 000000000..320410b2e
--- /dev/null
+++ b/js/webpack/app.js
@@ -0,0 +1,158 @@
+
+// Copyright 2015, 2016 Ethcore (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
.
+
+const webpack = require('webpack');
+const path = require('path');
+const WebpackErrorNotificationPlugin = require('webpack-error-notification');
+const CopyWebpackPlugin = require('copy-webpack-plugin');
+const HtmlWebpackPlugin = require('html-webpack-plugin');
+
+const Shared = require('./shared');
+const DAPPS = require('../src/dapps');
+
+const FAVICON = path.resolve(__dirname, '../assets/images/parity-logo-black-no-text.png');
+
+const DEST = process.env.BUILD_DEST || '.build';
+const ENV = process.env.NODE_ENV || 'development';
+const isProd = ENV === 'production';
+
+module.exports = {
+ cache: !isProd,
+ devtool: isProd ? '#eval' : '#cheap-module-eval-source-map',
+
+ context: path.join(__dirname, '../src'),
+ entry: Object.assign({}, Shared.dappsEntry, {
+ index: './index.js'
+ }),
+ output: {
+ publicPath: '/',
+ path: path.join(__dirname, '../', DEST),
+ filename: '[name].[hash].js'
+ },
+
+ module: {
+ rules: [
+ {
+ test: /\.js$/,
+ exclude: /node_modules/,
+ // use: [ 'happypack/loader?id=js' ]
+ use: isProd ? ['babel-loader'] : [
+ 'babel-loader?cacheDirectory=true'
+ ],
+ options: Shared.getBabelrc()
+ },
+ {
+ test: /\.js$/,
+ include: /node_modules\/material-ui-chip-input/,
+ use: [ 'babel-loader' ]
+ },
+ {
+ test: /\.json$/,
+ use: [ 'json-loader' ]
+ },
+ {
+ test: /\.html$/,
+ use: [
+ 'file-loader?name=[name].[ext]!extract-loader',
+ {
+ loader: 'html-loader',
+ options: {
+ root: path.resolve(__dirname, '../assets/images'),
+ attrs: ['img:src', 'link:href']
+ }
+ }
+ ]
+ },
+
+ {
+ test: /\.css$/,
+ include: [ /src/ ],
+ // use: [ 'happypack/loader?id=css' ]
+ use: [
+ 'style-loader',
+ 'css-loader?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
+ 'postcss-loader'
+ ]
+ },
+ {
+ test: /\.css$/,
+ exclude: [ /src/ ],
+ use: [ 'style-loader', 'css-loader' ]
+ },
+ {
+ test: /\.(png|jpg)$/,
+ use: [ 'file-loader?name=[name].[hash].[ext]' ]
+ },
+ {
+ test: /\.(woff(2)|ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
+ use: [ 'file-loader' ]
+ }
+ ],
+ noParse: [
+ /node_modules\/sinon/
+ ]
+ },
+
+ resolve: {
+ modules: [
+ path.join(__dirname, '../node_modules')
+ ],
+ extensions: ['.json', '.js', '.jsx'],
+ unsafeCache: true
+ },
+
+ plugins: (function () {
+ const plugins = Shared.getPlugins().concat([
+ new CopyWebpackPlugin([{ from: './error_pages.css', to: 'styles.css' }], {}),
+ new WebpackErrorNotificationPlugin(),
+
+ new webpack.DllReferencePlugin({
+ context: '.',
+ manifest: require(`../${DEST}/vendor-manifest.json`)
+ }),
+
+ new HtmlWebpackPlugin({
+ title: 'Parity',
+ filename: 'index.html',
+ template: './index.ejs',
+ favicon: FAVICON,
+ chunks: [ isProd ? null : 'commons', 'index' ]
+ })
+ ], DAPPS.map((dapp) => {
+ return new HtmlWebpackPlugin({
+ title: dapp.title,
+ filename: dapp.name + '.html',
+ template: './dapps/index.ejs',
+ favicon: FAVICON,
+ secure: dapp.secure,
+ chunks: [ isProd ? null : 'commons', dapp.name ]
+ });
+ }));
+
+ if (!isProd) {
+ plugins.push(
+ new webpack.optimize.CommonsChunkPlugin({
+ filename: 'commons.[hash].js',
+ name: 'commons',
+ minChunks: Infinity
+ })
+ );
+ }
+
+ return plugins;
+ }())
+};
diff --git a/js/build-server.js b/js/webpack/build.server.js
similarity index 66%
rename from js/build-server.js
rename to js/webpack/build.server.js
index c10630ab0..c1e803f56 100644
--- a/js/build-server.js
+++ b/js/webpack/build.server.js
@@ -15,7 +15,7 @@
// along with Parity. If not, see
.
// test only
/**
- * Run `PARITY_URL="127.0.0.1:8180" NODE_ENV="production" npm run build`
+ * Run `DAPPS_URL="/" PARITY_URL="127.0.0.1:8180" NODE_ENV="production" npm run build`
* to build the project ; use this server to test that the minifed
* version is working (this is a simple proxy server)
*/
@@ -23,39 +23,17 @@
var express = require('express');
var proxy = require('http-proxy-middleware');
+var Shared = require('./shared');
+
var app = express();
var wsProxy = proxy('ws://127.0.0.1:8180', { changeOrigin: true });
+Shared.addProxies(app);
+
app.use(express.static('.build'));
-
-app.use('/api/*', proxy({
- target: 'http://127.0.0.1:8080',
- changeOrigin: true
-}));
-
-app.use('/app/*', proxy({
- target: 'http://127.0.0.1:8080',
- changeOrigin: true,
- pathRewrite: {
- '^/app': ''
- }
-}));
-
-app.use('/parity-utils/*', proxy({
- target: 'http://127.0.0.1:3000',
- changeOrigin: true,
- pathRewrite: {
- '^/parity-utils': ''
- }
-}));
-
-app.use('/rpc/*', proxy({
- target: 'http://127.0.0.1:8080',
- changeOrigin: true
-}));
-
app.use(wsProxy);
-var server = app.listen(3000);
-
+var server = app.listen(process.env.PORT || 3000, function () {
+ console.log('Listening on port', server.address().port);
+});
server.on('upgrade', wsProxy.upgrade);
diff --git a/js/webpack/dev.server.js b/js/webpack/dev.server.js
new file mode 100644
index 000000000..ca006fc98
--- /dev/null
+++ b/js/webpack/dev.server.js
@@ -0,0 +1,80 @@
+// Copyright 2015, 2016 Ethcore (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
.
+
+const webpack = require('webpack');
+const webpackDevMiddleware = require('webpack-dev-middleware');
+const webpackHotMiddleware = require('webpack-hot-middleware');
+
+const http = require('http');
+const express = require('express');
+const ProgressBar = require('progress');
+
+const webpackConfig = require('./app');
+const Shared = require('./shared');
+
+let progressBar = { update: () => {} };
+
+/**
+ * Add webpack hot middleware to each entry in the config
+ * and HMR to the plugins
+ */
+(function updateWebpackConfig () {
+ Object.keys(webpackConfig.entry).forEach((key) => {
+ const entry = webpackConfig.entry[key];
+
+ webpackConfig.entry[key] = [].concat(
+ 'react-hot-loader/patch',
+ 'webpack-hot-middleware/client?reload=true',
+ entry
+ );
+ });
+
+ webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
+ webpackConfig.plugins.push(new webpack.NamedModulesPlugin());
+ webpackConfig.plugins.push(new webpack.NoErrorsPlugin());
+
+ webpackConfig.plugins.push(new webpack.ProgressPlugin(
+ (percentage) => progressBar.update(percentage)
+ ));
+})();
+
+const app = express();
+const compiler = webpack(webpackConfig);
+
+app.use(webpackHotMiddleware(compiler, {
+ log: console.log
+}));
+
+app.use(webpackDevMiddleware(compiler, {
+ noInfo: false,
+ quiet: false,
+ progress: true,
+ publicPath: webpackConfig.output.publicPath,
+ stats: {
+ colors: true
+ }
+}));
+
+app.use(express.static(webpackConfig.output.path));
+
+// Add the dev proxies in the express App
+Shared.addProxies(app);
+
+const server = http.createServer(app);
+server.listen(process.env.PORT || 3000, function () {
+ console.log('Listening on port', server.address().port);
+ progressBar = new ProgressBar('[:bar] :percent :etas', { total: 50 });
+});
diff --git a/js/webpack.libraries.js b/js/webpack/libraries.js
similarity index 54%
rename from js/webpack.libraries.js
rename to js/webpack/libraries.js
index 889a45103..d1a2b4915 100644
--- a/js/webpack.libraries.js
+++ b/js/webpack/libraries.js
@@ -16,16 +16,16 @@
// Run with `webpack --config webpack.libraries.js --progress`
-const HappyPack = require('happypack');
const path = require('path');
-const webpack = require('webpack');
+const Shared = require('./shared');
+
+const DEST = process.env.BUILD_DEST || '.build';
const ENV = process.env.NODE_ENV || 'development';
const isProd = ENV === 'production';
-const DEST = process.env.BUILD_DEST || '.build';
module.exports = {
- context: path.join(__dirname, './src'),
+ context: path.join(__dirname, '../src'),
entry: {
// library
'inject': ['./web3.js'],
@@ -33,59 +33,31 @@ module.exports = {
'parity': ['./parity.js']
},
output: {
- path: path.join(__dirname, DEST),
+ path: path.join(__dirname, '../', DEST),
filename: '[name].js',
library: '[name].js',
libraryTarget: 'umd'
},
module: {
- loaders: [
+ rules: [
{
test: /\.js$/,
exclude: /node_modules/,
- loader: 'happypack/loader?id=js'
+ // use: [ 'happypack/loader?id=js' ]
+ use: isProd ? ['babel-loader'] : [
+ // 'react-hot-loader',
+ 'babel-loader?cacheDirectory=true'
+ ]
},
{
test: /\.json$/,
- loaders: ['json']
+ use: [ 'json-loader' ]
},
{
test: /\.html$/,
- loader: 'file?name=[name].[ext]'
+ use: [ 'file-loader?name=[name].[ext]' ]
}
]
},
- plugins: (function () {
- const plugins = [
- new HappyPack({
- id: 'js',
- threads: 4,
- loaders: [ 'babel' ]
- }),
- new webpack.DefinePlugin({
- 'process.env': {
- NODE_ENV: JSON.stringify(ENV),
- RPC_ADDRESS: JSON.stringify(process.env.RPC_ADDRESS),
- PARITY_URL: JSON.stringify(process.env.PARITY_URL),
- LOGGING: JSON.stringify(!isProd)
- }
- })
- ];
-
- if (isProd) {
- plugins.push(new webpack.optimize.OccurrenceOrderPlugin(false));
- plugins.push(new webpack.optimize.DedupePlugin());
- plugins.push(new webpack.optimize.UglifyJsPlugin({
- screwIe8: true,
- compress: {
- warnings: false
- },
- output: {
- comments: false
- }
- }));
- }
-
- return plugins;
- }())
+ plugins: Shared.getPlugins()
};
diff --git a/js/webpack.npm.js b/js/webpack/npm.js
similarity index 54%
rename from js/webpack.npm.js
rename to js/webpack/npm.js
index 80b6dd540..7353efe55 100644
--- a/js/webpack.npm.js
+++ b/js/webpack/npm.js
@@ -15,19 +15,20 @@
// along with Parity. If not, see
.
const path = require('path');
-const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
-const packageJson = require('./package.json');
+const packageJson = require('../package.json');
+
+const Shared = require('./shared');
const ENV = process.env.NODE_ENV || 'development';
const isProd = ENV === 'production';
module.exports = {
- context: path.join(__dirname, './src'),
+ context: path.join(__dirname, '../src'),
target: 'node',
entry: 'library.js',
output: {
- path: path.join(__dirname, '.npmjs'),
+ path: path.join(__dirname, '../.npmjs'),
filename: 'library.js',
library: 'Parity',
libraryTarget: 'umd',
@@ -41,52 +42,45 @@ module.exports = {
noParse: [
/babel-polyfill/
],
- loaders: [
+ rules: [
{
test: /(\.jsx|\.js)$/,
- loader: 'babel',
+ // use: [ 'happypack/loader?id=js' ],
+ use: isProd ? ['babel-loader'] : [
+ // 'react-hot-loader',
+ 'babel-loader?cacheDirectory=true'
+ ],
exclude: /node_modules/
}
]
},
+
resolve: {
- root: path.resolve('./src'),
- extensions: ['', '.js']
+ modules: [
+ path.resolve('./src'),
+ path.join(__dirname, '../node_modules')
+ ],
+ extensions: ['.json', '.js', '.jsx']
},
- plugins: (function () {
- const plugins = [
- new CopyWebpackPlugin([
- {
- from: '../parity.package.json',
- to: 'package.json',
- transform: function (content, path) {
- const json = JSON.parse(content.toString());
- json.version = packageJson.version;
- return new Buffer(JSON.stringify(json, null, ' '), 'utf-8');
- }
- },
- {
- from: '../LICENSE'
- },
- {
- from: '../parity.md',
- to: 'README.md'
- }
- ], { copyUnmodified: true })
- ];
- if (isProd) {
- plugins.push(new webpack.optimize.UglifyJsPlugin({
- screwIe8: true,
- compress: {
- warnings: false
- },
- output: {
- comments: false
+ plugins: Shared.getPlugins().concat([
+ new CopyWebpackPlugin([
+ {
+ from: '../parity.package.json',
+ to: 'package.json',
+ transform: function (content, path) {
+ const json = JSON.parse(content.toString());
+ json.version = packageJson.version;
+ return new Buffer(JSON.stringify(json, null, ' '), 'utf-8');
}
- }));
- }
-
- return plugins;
- }())
+ },
+ {
+ from: '../LICENSE'
+ },
+ {
+ from: '../parity.md',
+ to: 'README.md'
+ }
+ ], { copyUnmodified: true })
+ ])
};
diff --git a/js/webpack/shared.js b/js/webpack/shared.js
new file mode 100644
index 000000000..8887c41fb
--- /dev/null
+++ b/js/webpack/shared.js
@@ -0,0 +1,176 @@
+// Copyright 2015, 2016 Ethcore (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
.
+
+const webpack = require('webpack');
+const path = require('path');
+const fs = require('fs');
+// const HappyPack = require('happypack');
+
+const postcssImport = require('postcss-import');
+const postcssNested = require('postcss-nested');
+const postcssVars = require('postcss-simple-vars');
+const rucksack = require('rucksack-css');
+
+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;
+ return babelrc;
+}
+
+function getPlugins (_isProd = isProd) {
+ const postcss = [
+ postcssImport({
+ addDependencyTo: webpack
+ }),
+ postcssNested({}),
+ postcssVars({
+ unknown: function (node, name, result) {
+ node.warn(result, `Unknown variable ${name}`);
+ }
+ }),
+ rucksack({
+ autoprefixer: true
+ })
+ ];
+
+ const plugins = [
+ // NB: HappyPack is not yet working with Webpack 2... (as of Nov. 26)
+
+ // new HappyPack({
+ // id: 'css',
+ // threads: 4,
+ // loaders: [
+ // 'style-loader',
+ // 'css-loader?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
+ // 'postcss-loader'
+ // ]
+ // }),
+
+ // new HappyPack({
+ // id: 'js',
+ // threads: 4,
+ // loaders: _isProd ? ['babel'] : [
+ // 'react-hot-loader',
+ // 'babel-loader?cacheDirectory=true'
+ // ]
+ // }),
+
+ // new HappyPack({
+ // id: 'babel',
+ // threads: 4,
+ // loaders: ['babel-loader']
+ // }),
+
+ new webpack.DefinePlugin({
+ 'process.env': {
+ NODE_ENV: JSON.stringify(ENV),
+ RPC_ADDRESS: JSON.stringify(process.env.RPC_ADDRESS),
+ PARITY_URL: JSON.stringify(process.env.PARITY_URL),
+ DAPPS_URL: JSON.stringify(process.env.DAPPS_URL),
+ LOGGING: JSON.stringify(!isProd)
+ }
+ }),
+
+ new webpack.LoaderOptionsPlugin({
+ minimize: isProd,
+ debug: !isProd,
+ options: {
+ context: path.join(__dirname, '../src'),
+ postcss: postcss,
+ babel: getBabelrc()
+ }
+ }),
+
+ new webpack.optimize.OccurrenceOrderPlugin(!_isProd)
+ ];
+
+ if (_isProd) {
+ plugins.push(new webpack.optimize.UglifyJsPlugin({
+ screwIe8: true,
+ compress: {
+ warnings: false
+ },
+ output: {
+ comments: false
+ }
+ }));
+ }
+
+ return plugins;
+}
+
+function getDappsEntry () {
+ const DAPPS = require('../src/dapps');
+
+ return DAPPS.reduce((_entry, dapp) => {
+ _entry[dapp.name] = './dapps/' + dapp.entry;
+ return _entry;
+ }, {});
+}
+
+function addProxies (app) {
+ const proxy = require('http-proxy-middleware');
+
+ app.use(proxy((pathname, req) => {
+ return pathname === '/' && req.method === 'HEAD';
+ }, {
+ target: 'http://127.0.0.1:8180',
+ changeOrigin: true,
+ autoRewrite: true
+ }));
+
+ app.use('/api', proxy({
+ target: 'http://127.0.0.1:8080',
+ changeOrigin: true,
+ autoRewrite: true
+ }));
+
+ app.use('/app', proxy({
+ target: 'http://127.0.0.1:8080',
+ changeOrigin: true,
+ pathRewrite: {
+ '^/app': ''
+ }
+ }));
+
+ app.use('/parity-utils', proxy({
+ target: 'http://127.0.0.1:3000',
+ changeOrigin: true,
+ pathRewrite: {
+ '^/parity-utils': ''
+ }
+ }));
+
+ app.use('/rpc', proxy({
+ target: 'http://127.0.0.1:8080',
+ changeOrigin: true
+ }));
+}
+
+module.exports = {
+ getBabelrc: getBabelrc,
+ getPlugins: getPlugins,
+ dappsEntry: getDappsEntry(),
+ addProxies: addProxies
+};
diff --git a/js/webpack.vendor.js b/js/webpack/vendor.js
similarity index 56%
rename from js/webpack.vendor.js
rename to js/webpack/vendor.js
index 222f6ab4e..dfef25464 100644
--- a/js/webpack.vendor.js
+++ b/js/webpack/vendor.js
@@ -14,11 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see
.
-const HappyPack = require('happypack');
const webpack = require('webpack');
+const path = require('path');
+
+const Shared = require('./shared');
const ENV = process.env.NODE_ENV || 'development';
-const isProd = ENV === 'production';
const DEST = process.env.BUILD_DEST || '.build';
let modules = [
@@ -45,69 +46,38 @@ let modules = [
'scryptsy'
];
-if (!isProd) {
- modules = modules.concat([
- 'webpack-dev-server/client?http://localhost:3000',
- 'react-hot-loader', 'core-js', 'core-js/library'
- ]);
-}
-
module.exports = {
entry: {
vendor: modules
},
module: {
- loaders: [
+ rules: [
{
test: /\.json$/,
- loaders: ['json']
+ use: [ 'json-loader' ]
},
{
test: /\.js$/,
include: /(ethereumjs-tx)/,
- loaders: [ 'happypack/loader?id=js' ]
+ use: [ 'babel-loader' ]
}
]
},
output: {
filename: '[name].js',
- path: `${DEST}/`,
+ path: path.resolve(__dirname, '../', `${DEST}/`),
library: '[name]_lib'
},
- plugins: (function () {
- const plugins = [
- new webpack.DllPlugin({
- name: '[name]_lib',
- path: `${DEST}/[name]-manifest.json`
- }),
+ plugins: Shared.getPlugins().concat([
+ new webpack.DllPlugin({
+ name: '[name]_lib',
+ path: path.resolve(__dirname, '../', `${DEST}/[name]-manifest.json`)
+ }),
- new webpack.DefinePlugin({
- 'process.env': {
- NODE_ENV: JSON.stringify(ENV)
- }
- }),
-
- new HappyPack({
- id: 'js',
- threads: 4,
- loaders: ['babel']
- })
- ];
-
- if (isProd) {
- plugins.push(new webpack.optimize.OccurrenceOrderPlugin(false));
- plugins.push(new webpack.optimize.DedupePlugin());
- plugins.push(new webpack.optimize.UglifyJsPlugin({
- screwIe8: true,
- compress: {
- warnings: false
- },
- output: {
- comments: false
- }
- }));
- }
-
- return plugins;
- }())
+ new webpack.DefinePlugin({
+ 'process.env': {
+ NODE_ENV: JSON.stringify(ENV)
+ }
+ })
+ ])
};