From ed7cd7a9f0f7894a77c70698f2732bd10f69be4e Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Mon, 26 Sep 2016 13:17:50 +0100 Subject: [PATCH 1/3] Removing PropTypes on build // Simple express server to test builds (#2157) --- js/.babelrc | 14 ++++++++++++-- js/build-server.js | 18 ++++++++++++++++++ js/package.json | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 js/build-server.js diff --git a/js/.babelrc b/js/.babelrc index b0b0d0ffa58..27c69788555 100644 --- a/js/.babelrc +++ b/js/.babelrc @@ -1,5 +1,15 @@ { "presets": ["es2017", "es2016", "es2015", "stage-0", "react"], - "plugins": ["transform-runtime", "transform-decorators-legacy", "transform-class-properties", "lodash"], - "retainLines": true + "plugins": [ + "transform-runtime", + "transform-decorators-legacy", + "transform-class-properties", + "lodash" + ], + "retainLines": true, + "env": { + "production": { + "plugins": ["transform-react-remove-prop-types"] + } + } } diff --git a/js/build-server.js b/js/build-server.js new file mode 100644 index 00000000000..0afc2e5ae52 --- /dev/null +++ b/js/build-server.js @@ -0,0 +1,18 @@ +var express = require('express'); +var proxy = require('http-proxy-middleware'); + +var app = express(); + +app.use(express.static('build')); + +app.use('/api/*', proxy({ + target: 'http://127.0.0.1:8080', + changeOrigin: true +})); + +app.use('/rpc/*', proxy({ + target: 'http://localhost:8080', + changeOrigin: true +})); + +app.listen(3000); diff --git a/js/package.json b/js/package.json index 40ae0dab74c..cc0b75af315 100644 --- a/js/package.json +++ b/js/package.json @@ -44,6 +44,7 @@ "babel-plugin-lodash": "^3.2.2", "babel-plugin-transform-class-properties": "^6.11.5", "babel-plugin-transform-decorators-legacy": "^1.3.4", + "babel-plugin-transform-react-remove-prop-types": "^0.2.9", "babel-plugin-transform-runtime": "^6.9.0", "babel-polyfill": "^6.13.0", "babel-preset-es2015": "^6.9.0", From a1ac6cfc3680479b706df223cdb62ab04c8a96f1 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Mon, 26 Sep 2016 13:37:38 +0100 Subject: [PATCH 2/3] Working Proxy server // Vendors build fixed (#2157) --- js/build-server.js | 8 +++++++- js/src/index.js | 7 ++++++- js/webpack.config.js | 1 + js/webpack.vendor.js | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/js/build-server.js b/js/build-server.js index 0afc2e5ae52..71017ee6e1c 100644 --- a/js/build-server.js +++ b/js/build-server.js @@ -1,3 +1,9 @@ +/** + * Run `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) + */ + var express = require('express'); var proxy = require('http-proxy-middleware'); @@ -11,7 +17,7 @@ app.use('/api/*', proxy({ })); app.use('/rpc/*', proxy({ - target: 'http://localhost:8080', + target: 'http://127.0.0.1:8080', changeOrigin: true })); diff --git a/js/src/index.js b/js/src/index.js index 1a4d9643065..9cc0d16dc9e 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -46,7 +46,12 @@ import './index.html'; injectTapEventPlugin(); const initToken = window.localStorage.getItem('sysuiToken'); -const parityUrl = process.env.NODE_ENV === 'production' ? window.location.host : '127.0.0.1:8180'; +const parityUrl = process.env.PARITY_URL || + ( + process.env.NODE_ENV === 'production' + ? window.location.host + : '127.0.0.1:8180' + ); const api = new Api(new Api.Transport.Ws(`ws://${parityUrl}`, initToken)); // new Api.Transport.Http('/rpc/')); diff --git a/js/webpack.config.js b/js/webpack.config.js index cd63c0d134a..1261a02bb29 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -139,6 +139,7 @@ module.exports = { '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) } }) diff --git a/js/webpack.vendor.js b/js/webpack.vendor.js index 749f93e8a84..a62fecb99e0 100644 --- a/js/webpack.vendor.js +++ b/js/webpack.vendor.js @@ -56,6 +56,12 @@ module.exports = { new webpack.DllPlugin({ name: '[name]_lib', path: 'build/[name]-manifest.json' + }), + + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: JSON.stringify(ENV) + } }) ]; From 6fd63c7f9a6092b1ba3731a45b206e28255cd593 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Mon, 26 Sep 2016 15:35:41 +0100 Subject: [PATCH 3/3] Added GPL --- js/build-server.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/build-server.js b/js/build-server.js index 71017ee6e1c..797e89183ce 100644 --- a/js/build-server.js +++ b/js/build-server.js @@ -1,3 +1,19 @@ +// 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 . + /** * Run `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