Add inject to "bundle everything" list (#2871)
* Add inject to "bundle everything" list * Fixes the `build-server` script // Updates Webpack config (#2872) * New Webpack config file for libraries * Added `parity-utils` path * Removed parity in CommonChunks prod
This commit is contained in:
parent
71e973cb0b
commit
c8809b3396
@ -24,17 +24,38 @@ var express = require('express');
|
|||||||
var proxy = require('http-proxy-middleware');
|
var proxy = require('http-proxy-middleware');
|
||||||
|
|
||||||
var app = express();
|
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({
|
app.use('/api/*', proxy({
|
||||||
target: 'http://127.0.0.1:8080',
|
target: 'http://127.0.0.1:8080',
|
||||||
changeOrigin: true
|
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({
|
app.use('/rpc/*', proxy({
|
||||||
target: 'http://127.0.0.1:8080',
|
target: 'http://127.0.0.1:8080',
|
||||||
changeOrigin: true
|
changeOrigin: true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
app.listen(3000);
|
app.use(wsProxy);
|
||||||
|
|
||||||
|
var server = app.listen(3000);
|
||||||
|
|
||||||
|
server.on('upgrade', wsProxy.upgrade);
|
||||||
|
@ -23,17 +23,22 @@
|
|||||||
"Promise"
|
"Promise"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build:dll && npm run build:app",
|
"build": "npm run build:dll && npm run build:app && npm run build:lib",
|
||||||
"build:app": "webpack --progress",
|
"build:app": "webpack --progress",
|
||||||
"build:dll": "webpack --config webpack.vendor.js --progress",
|
"build:lib": "webpack --config webpack.libraries --progress",
|
||||||
"ci:build": "npm run ci:build:dll && npm run ci:build:app",
|
"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: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",
|
"clean": "rm -rf ./build ./coverage",
|
||||||
"coveralls": "npm run testCoverage && coveralls < coverage/lcov.info",
|
"coveralls": "npm run testCoverage && coveralls < coverage/lcov.info",
|
||||||
"lint": "eslint --ignore-path .gitignore ./src/",
|
"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": "mocha 'src/**/*.spec.js'",
|
||||||
"test:coverage": "istanbul cover _mocha -- 'src/**/*.spec.js'",
|
"test:coverage": "istanbul cover _mocha -- 'src/**/*.spec.js'",
|
||||||
"test:e2e": "mocha 'src/**/*.e2e.js'"
|
"test:e2e": "mocha 'src/**/*.e2e.js'"
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<div id="container"></div>
|
<div id="container"></div>
|
||||||
<script src="vendor.js"></script>
|
<script src="vendor.js"></script>
|
||||||
<script src="commons.js"></script>
|
<script src="commons.js"></script>
|
||||||
<script src="parity.js"></script>
|
<script src="/parity-utils/parity.js"></script>
|
||||||
<script src="basiccoin.js"></script>
|
<script src="basiccoin.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<div id="container"></div>
|
<div id="container"></div>
|
||||||
<script src="vendor.js"></script>
|
<script src="vendor.js"></script>
|
||||||
<script src="commons.js"></script>
|
<script src="commons.js"></script>
|
||||||
<script src="parity.js"></script>
|
<script src="/parity-utils/parity.js"></script>
|
||||||
<script src="gavcoin.js"></script>
|
<script src="gavcoin.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<div id="container"></div>
|
<div id="container"></div>
|
||||||
<script src="vendor.js"></script>
|
<script src="vendor.js"></script>
|
||||||
<script src="commons.js"></script>
|
<script src="commons.js"></script>
|
||||||
<script src="parity.js"></script>
|
<script src="/parity-utils/parity.js"></script>
|
||||||
<script src="githubhint.js"></script>
|
<script src="githubhint.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<div id="container"></div>
|
<div id="container"></div>
|
||||||
<script src="vendor.js"></script>
|
<script src="vendor.js"></script>
|
||||||
<script src="commons.js"></script>
|
<script src="commons.js"></script>
|
||||||
<script src="parity.js"></script>
|
<script src="/parity-utils/parity.js"></script>
|
||||||
<script src="registry.js"></script>
|
<script src="registry.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<div id="container"></div>
|
<div id="container"></div>
|
||||||
<script src="vendor.js"></script>
|
<script src="vendor.js"></script>
|
||||||
<script src="commons.js"></script>
|
<script src="commons.js"></script>
|
||||||
<script src="parity.js"></script>
|
<script src="/parity-utils/parity.js"></script>
|
||||||
<script src="signaturereg.js"></script>
|
<script src="signaturereg.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<div id="container"></div>
|
<div id="container"></div>
|
||||||
<script src="vendor.js"></script>
|
<script src="vendor.js"></script>
|
||||||
<script src="commons.js"></script>
|
<script src="commons.js"></script>
|
||||||
<script src="parity.js"></script>
|
<script src="/parity-utils/parity.js"></script>
|
||||||
<script src="tokenreg.js"></script>
|
<script src="tokenreg.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
<title>dev::Parity.js</title>
|
<title>dev::Parity.js</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script src="parity.js"></script>
|
<script src="/parity-utils/parity.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
<title>dev::Web3</title>
|
<title>dev::Web3</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script src="inject.js"></script>
|
<script src="/parity-utils/web3.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -19,7 +19,13 @@
|
|||||||
|
|
||||||
import './tests';
|
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 {
|
export {
|
||||||
parityNode
|
parityNode
|
||||||
|
@ -41,8 +41,9 @@ module.exports = {
|
|||||||
'signaturereg': ['./dapps/signaturereg.js'],
|
'signaturereg': ['./dapps/signaturereg.js'],
|
||||||
'tokenreg': ['./dapps/tokenreg.js'],
|
'tokenreg': ['./dapps/tokenreg.js'],
|
||||||
// library
|
// library
|
||||||
'inject': ['./inject.js'],
|
|
||||||
'parity': ['./parity.js'],
|
'parity': ['./parity.js'],
|
||||||
|
'inject': ['./web3.js'],
|
||||||
|
'web3': ['./web3.js'],
|
||||||
// app
|
// app
|
||||||
'index': ['./index.js']
|
'index': ['./index.js']
|
||||||
},
|
},
|
||||||
@ -136,10 +137,6 @@ module.exports = {
|
|||||||
'babel?cacheDirectory=true'
|
'babel?cacheDirectory=true'
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
new webpack.DllReferencePlugin({
|
|
||||||
context: '.',
|
|
||||||
manifest: require(`./${DEST}/vendor-manifest.json`)
|
|
||||||
}),
|
|
||||||
new CopyWebpackPlugin([{ from: './error_pages.css', to: 'styles.css' }], {}),
|
new CopyWebpackPlugin([{ from: './error_pages.css', to: 'styles.css' }], {}),
|
||||||
new WebpackErrorNotificationPlugin(),
|
new WebpackErrorNotificationPlugin(),
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
@ -149,6 +146,11 @@ module.exports = {
|
|||||||
PARITY_URL: JSON.stringify(process.env.PARITY_URL),
|
PARITY_URL: JSON.stringify(process.env.PARITY_URL),
|
||||||
LOGGING: JSON.stringify(!isProd)
|
LOGGING: JSON.stringify(!isProd)
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
new webpack.DllReferencePlugin({
|
||||||
|
context: '.',
|
||||||
|
manifest: require(`./${DEST}/vendor-manifest.json`)
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -164,16 +166,10 @@ module.exports = {
|
|||||||
if (isProd) {
|
if (isProd) {
|
||||||
plugins.push(
|
plugins.push(
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
chunks: [ 'index' ],
|
chunks: ['index'],
|
||||||
name: 'commons'
|
name: 'commons'
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
plugins.push(
|
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
|
||||||
chunks: [ 'parity' ],
|
|
||||||
name: 'parity'
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
plugins.push(new webpack.optimize.OccurrenceOrderPlugin(false));
|
plugins.push(new webpack.optimize.OccurrenceOrderPlugin(false));
|
||||||
plugins.push(new webpack.optimize.DedupePlugin());
|
plugins.push(new webpack.optimize.DedupePlugin());
|
||||||
@ -208,8 +204,11 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'/parity-utils/*': {
|
'/parity-utils/*': {
|
||||||
target: 'http://127.0.0.1:8080',
|
target: 'http://127.0.0.1:3000',
|
||||||
changeOrigin: true
|
changeOrigin: true,
|
||||||
|
pathRewrite: {
|
||||||
|
'^/parity-utils': ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'/rpc/*': {
|
'/rpc/*': {
|
||||||
target: 'http://localhost:8080',
|
target: 'http://localhost:8080',
|
||||||
|
89
js/webpack.libraries.js
Normal file
89
js/webpack.libraries.js
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}())
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user