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:
Jaco Greeff 2016-10-26 13:44:38 +02:00 committed by GitHub
parent 71e973cb0b
commit c8809b3396
14 changed files with 151 additions and 31 deletions

View File

@ -24,17 +24,38 @@ 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:3000',
changeOrigin: true,
pathRewrite: {
'^/parity-utils': ''
}
}));
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);

View File

@ -23,17 +23,22 @@
"Promise"
],
"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: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'"

View File

@ -10,7 +10,7 @@
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="parity.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="basiccoin.js"></script>
</body>
</html>

View File

@ -10,7 +10,7 @@
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="parity.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="gavcoin.js"></script>
</body>
</html>

View File

@ -10,7 +10,7 @@
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="parity.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="githubhint.js"></script>
</body>
</html>

View File

@ -10,7 +10,7 @@
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="parity.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="registry.js"></script>
</body>
</html>

View File

@ -10,7 +10,7 @@
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="parity.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="signaturereg.js"></script>
</body>
</html>

View File

@ -10,7 +10,7 @@
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="parity.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="tokenreg.js"></script>
</body>
</html>

View File

@ -7,6 +7,6 @@
<title>dev::Parity.js</title>
</head>
<body>
<script src="parity.js"></script>
<script src="/parity-utils/parity.js"></script>
</body>
</html>

View File

@ -7,6 +7,6 @@
<title>dev::Web3</title>
</head>
<body>
<script src="inject.js"></script>
<script src="/parity-utils/web3.js"></script>
</body>
</html>

View File

@ -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

View File

@ -41,8 +41,9 @@ module.exports = {
'signaturereg': ['./dapps/signaturereg.js'],
'tokenreg': ['./dapps/tokenreg.js'],
// library
'inject': ['./inject.js'],
'parity': ['./parity.js'],
'inject': ['./web3.js'],
'web3': ['./web3.js'],
// app
'index': ['./index.js']
},
@ -136,10 +137,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({
@ -149,6 +146,11 @@ module.exports = {
PARITY_URL: JSON.stringify(process.env.PARITY_URL),
LOGGING: JSON.stringify(!isProd)
}
}),
new webpack.DllReferencePlugin({
context: '.',
manifest: require(`./${DEST}/vendor-manifest.json`)
})
];
@ -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());
@ -208,8 +204,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',

89
js/webpack.libraries.js Normal file
View 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;
}())
};