From 7c7a36c0acb892fd3daff358fc055e571f4b6938 Mon Sep 17 00:00:00 2001 From: GitLab Build Bot Date: Tue, 25 Oct 2016 21:28:48 +0200 Subject: [PATCH 1/7] Add inject to "bundle everything" list --- js/webpack.config.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/webpack.config.js b/js/webpack.config.js index 39415b1a1f0..d7f9a7a8268 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -164,13 +164,19 @@ module.exports = { if (isProd) { plugins.push( new webpack.optimize.CommonsChunkPlugin({ - chunks: [ 'index' ], + chunks: ['index'], name: 'commons' }) ); plugins.push( new webpack.optimize.CommonsChunkPlugin({ - chunks: [ 'parity' ], + chunks: ['inject'], + name: 'inject' + }) + ); + plugins.push( + new webpack.optimize.CommonsChunkPlugin({ + chunks: ['parity'], name: 'parity' }) ); From 55e5d740f32a0ae8f2a243ec26062567fdef4018 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 26 Oct 2016 11:45:29 +0200 Subject: [PATCH 2/7] Fixes the `build-server` script // Updates Webpack config (#2872) --- js/build-server.js | 22 ++++++++++++++++++++-- js/package.json | 2 +- js/src/environment/index.js | 8 +++++++- js/webpack.config.js | 11 +++++++---- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/js/build-server.js b/js/build-server.js index 797e89183ce..3d564ffa447 100644 --- a/js/build-server.js +++ b/js/build-server.js @@ -24,17 +24,35 @@ var express = require('express'); var proxy = require('http-proxy-middleware'); var app = express(); +var wsProxy = proxy('ws://127.0.0.1:8180', { changeOrigin: true }); -app.use(express.static('build')); +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:8080', + changeOrigin: true +})); + app.use('/rpc/*', proxy({ target: 'http://127.0.0.1:8080', changeOrigin: true })); -app.listen(3000); +app.use(wsProxy); + +var server = app.listen(3000); + +server.on('upgrade', wsProxy.upgrade); diff --git a/js/package.json b/js/package.json index d84b21d2532..a4a0b6004b7 100644 --- a/js/package.json +++ b/js/package.json @@ -23,7 +23,7 @@ "Promise" ], "scripts": { - "build": "npm run build:dll && npm run build:app", + "build": "npm run build:app", "build:app": "webpack --progress", "build:dll": "webpack --config webpack.vendor.js --progress", "ci:build": "npm run ci:build:dll && npm run ci:build:app", diff --git a/js/src/environment/index.js b/js/src/environment/index.js index 1dfda77aa61..9b95bb0dada 100644 --- a/js/src/environment/index.js +++ b/js/src/environment/index.js @@ -19,7 +19,13 @@ import './tests'; -const parityNode = process.env.NODE_ENV === 'production' ? 'http://127.0.0.1:8080' : ''; +const parityNode = ( + process.env.PARITY_URL && `http://${process.env.PARITY_URL}` + ) || ( + process.env.NODE_ENV === 'production' + ? 'http://127.0.0.1:8080' + : '' + ); export { parityNode diff --git a/js/webpack.config.js b/js/webpack.config.js index d7f9a7a8268..0450add869f 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -136,10 +136,6 @@ module.exports = { 'babel?cacheDirectory=true' ] }), - new webpack.DllReferencePlugin({ - context: '.', - manifest: require(`./${DEST}/vendor-manifest.json`) - }), new CopyWebpackPlugin([{ from: './error_pages.css', to: 'styles.css' }], {}), new WebpackErrorNotificationPlugin(), new webpack.DefinePlugin({ @@ -153,6 +149,13 @@ module.exports = { ]; if (!isProd) { + plugins.push( + new webpack.DllReferencePlugin({ + context: '.', + manifest: require(`./${DEST}/vendor-manifest.json`) + }) + ); + plugins.push( new webpack.optimize.CommonsChunkPlugin({ filename: 'commons.js', From 32c60de76ff47d9890773e5eb2389f5a36c16bd8 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 26 Oct 2016 12:32:22 +0200 Subject: [PATCH 3/7] New Webpack config file for libraries --- js/package.json | 19 +++++--- js/src/dev.web3.html | 2 +- js/src/{inject.js => web3.js} | 0 js/webpack.config.js | 19 ++------ js/webpack.libraries.js | 89 +++++++++++++++++++++++++++++++++++ 5 files changed, 107 insertions(+), 22 deletions(-) rename js/src/{inject.js => web3.js} (100%) create mode 100644 js/webpack.libraries.js diff --git a/js/package.json b/js/package.json index a4a0b6004b7..433d55fc198 100644 --- a/js/package.json +++ b/js/package.json @@ -1,4 +1,4 @@ -{ + { "name": "parity.js", "version": "0.0.1", "main": "release/index.js", @@ -23,17 +23,22 @@ "Promise" ], "scripts": { - "build": "npm run build:app", + "build": "npm run build:dll && npm run build:app && npm run build:lib", "build:app": "webpack --progress", - "build:dll": "webpack --config webpack.vendor.js --progress", - "ci:build": "npm run ci:build:dll && npm run ci:build:app", + "build:lib": "webpack --config webpack.libraries --progress", + "build:dll": "webpack --config webpack.vendor --progress", + + "ci:build": "npm run ci:build:dll && npm run ci:build:dll && npm run ci:build:app", "ci:build:app": "NODE_ENV=production webpack", - "ci:build:dll": "NODE_ENV=production webpack --config webpack.vendor.js", + "ci:build:lib": "NODE_ENV=production webpack --config webpack.libraries", + "ci:build:dll": "NODE_ENV=production webpack --config webpack.vendor", + + "start": "npm install && npm run build:dll && npm run start:app", + "start:app": "webpack-dev-server -d --history-api-fallback --open --hot --inline --progress --colors --port 3000", + "clean": "rm -rf ./build ./coverage", "coveralls": "npm run testCoverage && coveralls < coverage/lcov.info", "lint": "eslint --ignore-path .gitignore ./src/", - "start": "npm install && npm run build:dll && npm run start:app", - "start:app": "webpack-dev-server -d --history-api-fallback --open --hot --inline --progress --colors --port 3000", "test": "mocha 'src/**/*.spec.js'", "test:coverage": "istanbul cover _mocha -- 'src/**/*.spec.js'", "test:e2e": "mocha 'src/**/*.e2e.js'" diff --git a/js/src/dev.web3.html b/js/src/dev.web3.html index 97a47eb72d5..c577887c781 100644 --- a/js/src/dev.web3.html +++ b/js/src/dev.web3.html @@ -7,6 +7,6 @@ dev::Web3 - + diff --git a/js/src/inject.js b/js/src/web3.js similarity index 100% rename from js/src/inject.js rename to js/src/web3.js diff --git a/js/webpack.config.js b/js/webpack.config.js index 0450add869f..38047a6ac85 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -41,7 +41,6 @@ module.exports = { 'signaturereg': ['./dapps/signaturereg.js'], 'tokenreg': ['./dapps/tokenreg.js'], // library - 'inject': ['./inject.js'], 'parity': ['./parity.js'], // app 'index': ['./index.js'] @@ -145,17 +144,15 @@ module.exports = { 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.DllReferencePlugin({ - context: '.', - manifest: require(`./${DEST}/vendor-manifest.json`) - }) - ); - plugins.push( new webpack.optimize.CommonsChunkPlugin({ filename: 'commons.js', @@ -171,12 +168,6 @@ module.exports = { name: 'commons' }) ); - plugins.push( - new webpack.optimize.CommonsChunkPlugin({ - chunks: ['inject'], - name: 'inject' - }) - ); plugins.push( new webpack.optimize.CommonsChunkPlugin({ chunks: ['parity'], diff --git a/js/webpack.libraries.js b/js/webpack.libraries.js new file mode 100644 index 00000000000..bf54a933f50 --- /dev/null +++ b/js/webpack.libraries.js @@ -0,0 +1,89 @@ +// 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 with `webpack --config webpack.libraries.js --progress` + +const HappyPack = require('happypack'); +const path = require('path'); +const webpack = require('webpack'); + +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'), + entry: { + // library + 'inject': ['./web3.js'], + 'web3': ['./web3.js'], + 'parity': ['./parity.js'] + }, + output: { + path: path.join(__dirname, DEST), + filename: '[name].js' + }, + module: { + loaders: [ + { + test: /\.js$/, + exclude: /node_modules/, + loader: 'happypack/loader?id=js' + }, + { + test: /\.json$/, + loaders: ['json'] + }, + { + test: /\.html$/, + loader: 'file?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; + }()) +}; From 9f4fab5180281991a8c5765a0f1a4b033c562491 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 26 Oct 2016 13:09:31 +0200 Subject: [PATCH 4/7] Added `parity-utils` path --- js/build-server.js | 7 +++++-- js/package.json | 2 +- js/src/dapps/basiccoin.html | 2 +- js/src/dapps/gavcoin.html | 2 +- js/src/dapps/githubhint.html | 2 +- js/src/dapps/registry.html | 2 +- js/src/dapps/signaturereg.html | 2 +- js/src/dapps/tokenreg.html | 2 +- js/src/dev.parity.html | 2 +- js/src/dev.web3.html | 2 +- js/webpack.config.js | 7 +++++-- 11 files changed, 19 insertions(+), 13 deletions(-) diff --git a/js/build-server.js b/js/build-server.js index 3d564ffa447..9153f5ed281 100644 --- a/js/build-server.js +++ b/js/build-server.js @@ -42,8 +42,11 @@ app.use('/app/*', proxy({ })); app.use('/parity-utils/*', proxy({ - target: 'http://127.0.0.1:8080', - changeOrigin: true + target: 'http://127.0.0.1:3000', + changeOrigin: true, + pathRewrite: { + '^/parity-utils': '' + } })); app.use('/rpc/*', proxy({ diff --git a/js/package.json b/js/package.json index 433d55fc198..8992c7fa667 100644 --- a/js/package.json +++ b/js/package.json @@ -1,4 +1,4 @@ - { +{ "name": "parity.js", "version": "0.0.1", "main": "release/index.js", diff --git a/js/src/dapps/basiccoin.html b/js/src/dapps/basiccoin.html index 9bcc368f388..7ac5cb3cbf5 100644 --- a/js/src/dapps/basiccoin.html +++ b/js/src/dapps/basiccoin.html @@ -10,7 +10,7 @@
- + diff --git a/js/src/dapps/gavcoin.html b/js/src/dapps/gavcoin.html index 928310a5262..f777f292057 100644 --- a/js/src/dapps/gavcoin.html +++ b/js/src/dapps/gavcoin.html @@ -10,7 +10,7 @@
- + diff --git a/js/src/dapps/githubhint.html b/js/src/dapps/githubhint.html index 0084dd051c1..085b15953f7 100644 --- a/js/src/dapps/githubhint.html +++ b/js/src/dapps/githubhint.html @@ -10,7 +10,7 @@
- + diff --git a/js/src/dapps/registry.html b/js/src/dapps/registry.html index 21b09dc12f3..83c5e8c9b08 100644 --- a/js/src/dapps/registry.html +++ b/js/src/dapps/registry.html @@ -10,7 +10,7 @@
- + diff --git a/js/src/dapps/signaturereg.html b/js/src/dapps/signaturereg.html index 3f74be28ab3..be62400d239 100644 --- a/js/src/dapps/signaturereg.html +++ b/js/src/dapps/signaturereg.html @@ -10,7 +10,7 @@
- + diff --git a/js/src/dapps/tokenreg.html b/js/src/dapps/tokenreg.html index ecb03d0055b..bcf04e2982f 100644 --- a/js/src/dapps/tokenreg.html +++ b/js/src/dapps/tokenreg.html @@ -10,7 +10,7 @@
- + diff --git a/js/src/dev.parity.html b/js/src/dev.parity.html index 20b8e965fcd..56811f7c25d 100644 --- a/js/src/dev.parity.html +++ b/js/src/dev.parity.html @@ -7,6 +7,6 @@ dev::Parity.js - + diff --git a/js/src/dev.web3.html b/js/src/dev.web3.html index c577887c781..e55e0109bdb 100644 --- a/js/src/dev.web3.html +++ b/js/src/dev.web3.html @@ -7,6 +7,6 @@ dev::Web3 - + diff --git a/js/webpack.config.js b/js/webpack.config.js index 38047a6ac85..acd86c5dc90 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -208,8 +208,11 @@ module.exports = { } }, '/parity-utils/*': { - target: 'http://127.0.0.1:8080', - changeOrigin: true + target: 'http://127.0.0.1:3000', + changeOrigin: true, + pathRewrite: { + '^/parity-utils': '' + } }, '/rpc/*': { target: 'http://localhost:8080', From c9b9d2d2ad7174f56da36f2b8a9acdd159dce007 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 26 Oct 2016 13:14:54 +0200 Subject: [PATCH 5/7] Removed parity in CommonChunks prod --- js/webpack.config.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/js/webpack.config.js b/js/webpack.config.js index acd86c5dc90..c72ef893620 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -42,6 +42,8 @@ module.exports = { 'tokenreg': ['./dapps/tokenreg.js'], // library 'parity': ['./parity.js'], + 'inject': ['./web3.js'], + 'web3': ['./web3.js'], // app 'index': ['./index.js'] }, @@ -168,12 +170,6 @@ module.exports = { name: 'commons' }) ); - plugins.push( - new webpack.optimize.CommonsChunkPlugin({ - chunks: ['parity'], - name: 'parity' - }) - ); plugins.push(new webpack.optimize.OccurrenceOrderPlugin(false)); plugins.push(new webpack.optimize.DedupePlugin()); From 7878f1aa25cf8045935a8fa924d7f14dc139eb26 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 26 Oct 2016 14:55:08 +0200 Subject: [PATCH 6/7] Fixes CI build --- js/package.json | 2 +- js/webpack.config.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/js/package.json b/js/package.json index 8992c7fa667..bafb3efcda3 100644 --- a/js/package.json +++ b/js/package.json @@ -28,7 +28,7 @@ "build:lib": "webpack --config webpack.libraries --progress", "build:dll": "webpack --config webpack.vendor --progress", - "ci:build": "npm run ci:build:dll && npm run ci:build:dll && npm run ci:build:app", + "ci:build": "npm run ci:build:dll && npm run ci:build:app && npm run ci:build:lib", "ci:build:app": "NODE_ENV=production webpack", "ci:build:lib": "NODE_ENV=production webpack --config webpack.libraries", "ci:build:dll": "NODE_ENV=production webpack --config webpack.vendor", diff --git a/js/webpack.config.js b/js/webpack.config.js index c72ef893620..51337b9ef85 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -40,10 +40,6 @@ module.exports = { 'registry': ['./dapps/registry.js'], 'signaturereg': ['./dapps/signaturereg.js'], 'tokenreg': ['./dapps/tokenreg.js'], - // library - 'parity': ['./parity.js'], - 'inject': ['./web3.js'], - 'web3': ['./web3.js'], // app 'index': ['./index.js'] }, From 95bf876e14e722de4386297d96940cd1b30a92be Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 26 Oct 2016 16:14:20 +0200 Subject: [PATCH 7/7] Re-Add Libs in Webpack Config --- js/webpack.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/webpack.config.js b/js/webpack.config.js index 51337b9ef85..d253b659255 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -40,6 +40,10 @@ module.exports = { 'registry': ['./dapps/registry.js'], 'signaturereg': ['./dapps/signaturereg.js'], 'tokenreg': ['./dapps/tokenreg.js'], + // library + 'inject': ['./web3.js'], + 'web3': ['./web3.js'], + 'parity': ['./parity.js'], // app 'index': ['./index.js'] },