Update build to pull from external repos

This commit is contained in:
Jaco Greeff 2017-08-01 14:41:13 +02:00
parent c509733a30
commit f8bf4a1522
10 changed files with 607 additions and 828 deletions

711
js/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,16 +27,16 @@
], ],
"scripts": { "scripts": {
"build": "npm run build:lib && npm run build:app", "build": "npm run build:lib && npm run build:app",
"build:app": "parallel-webpack -p=2 --config webpack/app", "build:app": "webpack --progress --config webpack/app",
"build:lib": "parallel-webpack -p=2 --config webpack/libraries", "build:lib": "webpack --progress --config webpack/libraries",
"build:markdown": "babel-node ./scripts/build-rpc-markdown.js", "build:markdown": "babel-node ./scripts/build-rpc-markdown.js",
"build:json": "babel-node ./scripts/build-rpc-json.js", "build:json": "babel-node ./scripts/build-rpc-json.js",
"build:embed": "EMBED=1 node webpack/embed", "build:embed": "EMBED=1 node webpack/embed",
"build:i18n": "npm run clean && npm run build && babel-node ./scripts/build-i18n.js", "build:i18n": "npm run clean && npm run build && babel-node ./scripts/build-i18n.js",
"ci:build": "npm run ci:build:lib && npm run ci:build:app && npm run ci:build:embed", "ci:build": "npm run ci:build:lib && npm run ci:build:app && npm run ci:build:embed",
"ci:build:app": "NODE_ENV=production parallel-webpack -p=2 --config webpack/app", "ci:build:app": "NODE_ENV=production webpack --progress --config webpack/app",
"ci:build:lib": "NODE_ENV=production parallel-webpack -p=2 --config webpack/libraries", "ci:build:lib": "NODE_ENV=production webpack --progress --config webpack/libraries",
"ci:build:npm": "NODE_ENV=production parallel-webpack -p=2 --config webpack/npm", "ci:build:npm": "NODE_ENV=production webpack --progress --config webpack/npm",
"ci:build:jsonrpc": "babel-node ./scripts/build-rpc-json.js --output .npmjs/jsonrpc", "ci:build:jsonrpc": "babel-node ./scripts/build-rpc-json.js --output .npmjs/jsonrpc",
"ci:build:embed": "NODE_ENV=production EMBED=1 node webpack/embed", "ci:build:embed": "NODE_ENV=production EMBED=1 node webpack/embed",
"clean": "rm -rf ./.build ./.coverage ./.happypack ./build ./node_modules/.cache", "clean": "rm -rf ./.build ./.coverage ./.happypack ./build ./node_modules/.cache",
@ -50,7 +50,7 @@
"lint:js:cached": "eslint --cache --ignore-path .gitignore ./src/", "lint:js:cached": "eslint --cache --ignore-path .gitignore ./src/",
"lint:js:fix": "eslint --fix --ignore-path .gitignore ./src/", "lint:js:fix": "eslint --fix --ignore-path .gitignore ./src/",
"start": "npm run clean && npm install && npm run build:lib && npm run start:app", "start": "npm run clean && npm install && npm run build:lib && npm run start:app",
"start:app": "webpack-dev-server --progress --config webpack/app", "start:app": "node webpack/dev.server",
"test": "NODE_ENV=test mocha --compilers ejs:ejsify 'src/**/*.spec.js' 'packages/**/*.spec.js'", "test": "NODE_ENV=test mocha --compilers ejs:ejsify 'src/**/*.spec.js' 'packages/**/*.spec.js'",
"test:coverage": "NODE_ENV=test istanbul cover _mocha -- --compilers ejs:ejsify 'src/**/*.spec.js' 'packages/**/*.spec.js'", "test:coverage": "NODE_ENV=test istanbul cover _mocha -- --compilers ejs:ejsify 'src/**/*.spec.js' 'packages/**/*.spec.js'",
"test:e2e": "NODE_ENV=test mocha 'src/**/*.e2e.js' 'packages/**/*.e2e.js'", "test:e2e": "NODE_ENV=test mocha 'src/**/*.e2e.js' 'packages/**/*.e2e.js'",
@ -122,7 +122,6 @@
"mock-local-storage": "1.0.2", "mock-local-storage": "1.0.2",
"mock-socket": "6.0.4", "mock-socket": "6.0.4",
"nock": "9.0.7", "nock": "9.0.7",
"parallel-webpack": "2.1.0",
"postcss-import": "10.0.0", "postcss-import": "10.0.0",
"postcss-loader": "2.0.6", "postcss-loader": "2.0.6",
"postcss-nested": "2.1.0", "postcss-nested": "2.1.0",
@ -144,7 +143,7 @@
"to-source": "2.0.3", "to-source": "2.0.3",
"uglify-js": "2.8.22", "uglify-js": "2.8.22",
"url-loader": "0.5.7", "url-loader": "0.5.7",
"webpack": "2.4.1", "webpack": "3.3.0",
"webpack-bundle-size-analyzer": "2.5.0", "webpack-bundle-size-analyzer": "2.5.0",
"webpack-dev-middleware": "1.10.1", "webpack-dev-middleware": "1.10.1",
"webpack-dev-server": "2.6.1", "webpack-dev-server": "2.6.1",
@ -155,13 +154,9 @@
}, },
"dependencies": { "dependencies": {
"@parity/api": "paritytech/js-api#ade4a6750292a2918676039ea53eea20c4c728bc", "@parity/api": "paritytech/js-api#ade4a6750292a2918676039ea53eea20c4c728bc",
"@parity/dapps": "file:packages/dapps", "@parity/dapp-accounts": "paritytech/dapp-accounts#b4b7113ba8ea25d11dfc0ed6d6c93b85c8a7fac8",
"@parity/etherscan": "paritytech/js-etherscan#efe859ac7d2a8a3cc05e01c689b7fa58f47f8b87", "@parity/shared": "paritytech/js-shared#438912f286ca09209e53fda5808205fca2c62940",
"@parity/ledger": "file:packages/ledger",
"@parity/shapeshift": "file:packages/shapeshift",
"@parity/shared": "paritytech/js-shared#a83c71946d30d5b3bf976860a676add29c48ee24",
"@parity/ui": "paritytech/js-ui#037782bd16e8abf1c169143aa61749a44b94489b", "@parity/ui": "paritytech/js-ui#037782bd16e8abf1c169143aa61749a44b94489b",
"@parity/wordlist": "1.0.1",
"es6-error": "4.0.0", "es6-error": "4.0.0",
"es6-promise": "4.0.5", "es6-promise": "4.0.5",
"flat": "2.0.1", "flat": "2.0.1",
@ -170,14 +165,13 @@
"format-number": "2.0.1", "format-number": "2.0.1",
"isomorphic-fetch": "2.2.1", "isomorphic-fetch": "2.2.1",
"lodash": "4.17.2", "lodash": "4.17.2",
"loglevel": "1.4.1",
"moment": "2.17.0", "moment": "2.17.0",
"promise-worker": "1.1.1",
"prop-types": "15.5.10", "prop-types": "15.5.10",
"react": "15.6.1", "react": "15.6.1",
"react-dom": "15.6.1", "react-dom": "15.6.1",
"react-inspector": "paritytech/react-inspector", "react-inspector": "paritytech/react-inspector",
"react-intl": "2.1.5", "react-intl": "2.1.5",
"react-markdown": "2.5.0",
"react-router": "3.0.0", "react-router": "3.0.0",
"react-router-redux": "4.0.7", "react-router-redux": "4.0.7",
"react-tap-event-plugin": "2.0.1", "react-tap-event-plugin": "2.0.1",
@ -188,12 +182,9 @@
"redux-thunk": "2.1.0", "redux-thunk": "2.1.0",
"store": "1.3.20", "store": "1.3.20",
"sw-toolbox": "^3.6.0", "sw-toolbox": "^3.6.0",
"u2f-api": "0.0.9",
"u2f-api-polyfill": "0.4.3",
"useragent.js": "0.5.6", "useragent.js": "0.5.6",
"utf8": "2.1.2", "utf8": "2.1.2",
"web3": "0.17.0-beta", "web3": "0.17.0-beta",
"whatwg-fetch": "2.0.1", "whatwg-fetch": "2.0.1"
"worker-loader": "^0.8.0"
} }
} }

View File

@ -20,6 +20,7 @@ import { FormattedMessage } from 'react-intl';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import UpgradeStore from '@parity/shared/mobx/upgradeParity';
import { Errors } from '@parity/ui'; import { Errors } from '@parity/ui';
import Connection from '../Connection'; import Connection from '../Connection';
@ -31,7 +32,6 @@ import Requests from '../Requests';
import Snackbar from '../Snackbar'; import Snackbar from '../Snackbar';
import Status from '../Status'; import Status from '../Status';
import UpgradeParity from '../UpgradeParity'; import UpgradeParity from '../UpgradeParity';
import UpgradeStore from '../UpgradeParity/store';
import SyncWarning, { showSyncWarning } from '../SyncWarning'; import SyncWarning, { showSyncWarning } from '../SyncWarning';
import Store from './store'; import Store from './store';

View File

@ -102,12 +102,14 @@ export default class Dapp extends Component {
case 'local': case 'local':
src = `${dappsUrl}/${app.id}/`; src = `${dappsUrl}/${app.id}/`;
break; break;
case 'network': case 'network':
src = `${dappsUrl}/${app.contentHash}/`; src = `${dappsUrl}/${app.contentHash}/`;
break; break;
default: default:
let dapphost = process.env.DAPPS_URL || ( let dapphost = process.env.DAPPS_URL || (
process.env.NODE_ENV === 'production' && !app.secure process.env.NODE_ENV === 'production'
? `${dappsUrl}/ui` ? `${dappsUrl}/ui`
: '' : ''
); );
@ -116,7 +118,11 @@ export default class Dapp extends Component {
dapphost = ''; dapphost = '';
} }
src = `${dapphost}/${app.url}.html`; const appId = this.context.api.util.isHex(app.id)
? app.id
: this.context.api.sha3(app.url);
src = `${dapphost}/dapps/${appId}/index.html`;
break; break;
} }

View File

@ -27,11 +27,9 @@ import web3extensions from './web3.extensions';
function initProvider () { function initProvider () {
let [, appId] = window.location.pathname.split('/'); let [, appId] = window.location.pathname.split('/');
if (appId.indexOf('.html') !== -1) { console.log('window.location.pathname', window.location.pathname, appId);
appId = appId.replace('.html', '');
}
if (appId.substr(0, 2) !== '0x') { if (!Api.util.isHex(appId)) {
appId = Api.util.sha3(appId); appId = Api.util.sha3(appId);
} }

View File

@ -15,7 +15,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
const Api = require('@parity/api');
const path = require('path'); const path = require('path');
const flatten = require('lodash.flatten');
// const ReactIntlAggregatePlugin = require('react-intl-aggregate-webpack-plugin'); // const ReactIntlAggregatePlugin = require('react-intl-aggregate-webpack-plugin');
const WebpackErrorNotificationPlugin = require('webpack-error-notification'); const WebpackErrorNotificationPlugin = require('webpack-error-notification');
const CopyWebpackPlugin = require('copy-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin');
@ -27,10 +29,11 @@ const rulesParity = require('./rules/parity');
const Shared = require('./shared'); const Shared = require('./shared');
const DAPPS_BUILTIN = require('@parity/shared/config/dappsBuiltin.json'); const DAPPS_BUILTIN = require('@parity/shared/config/dappsBuiltin.json');
const DAPPS_VIEWS = require('@parity/shared/config/dappsViews.json').map((dapp) => { const DAPPS_VIEWS = require('@parity/shared/config/dappsViews.json');
dapp.commons = true; const DAPPS_ALL = []
return dapp; .concat(DAPPS_BUILTIN, DAPPS_VIEWS)
}); .filter((dapp) => !dapp.skipBuild)
.filter((dapp) => dapp.package);
const FAVICON = path.resolve(__dirname, '../node_modules/@parity/shared/assets/images/parity-logo-black-no-text.png'); const FAVICON = path.resolve(__dirname, '../node_modules/@parity/shared/assets/images/parity-logo-black-no-text.png');
@ -42,231 +45,207 @@ const isProd = ENV === 'production';
const isEmbed = EMBED === '1' || EMBED === 'true'; const isEmbed = EMBED === '1' || EMBED === 'true';
const entry = isEmbed const entry = isEmbed
? { ? { embed: './embed.js' }
embed: './embed.js' : { index: './index.js' };
}
: Object.assign({}, Shared.dappsEntry, {
index: './index.js'
});
module.exports = Object.keys(entry).map((entryName) => { module.exports = {
const entrySrc = entry[entryName]; cache: !isProd,
devtool: isProd ? '#hidden-source-map' : '#source-map',
return { context: path.join(__dirname, '../src'),
cache: !isProd, entry,
devtool: isProd ? '#hidden-source-map' : '#source-map', output: {
path: path.join(__dirname, '../', DEST),
filename: '[name].js'
},
context: path.join(__dirname, '../src'), module: {
entry: { rules: [
[entryName]: entrySrc rulesParity,
}, rulesEs6,
output: { {
path: path.join(__dirname, '../', DEST), test: /\.js$/,
filename: '[name].js' exclude: /(node_modules)/,
}, use: [ 'babel-loader' ]
module: {
rules: [
rulesParity,
rulesEs6,
{
test: /\.js$/,
exclude: /(node_modules)/,
use: [ 'babel-loader' ]
},
{
test: /\.json$/,
use: [ 'json-loader' ]
},
{
test: /\.ejs$/,
use: [ 'ejs-loader' ]
},
{
test: /\.html$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
},
'extract-loader',
{
loader: 'html-loader',
options: {
root: path.resolve(__dirname, '../assets/images'),
attrs: ['img:src', 'link:href']
}
}
]
},
{
test: /\.md$/,
use: [ 'html-loader', 'markdown-loader' ]
},
{
test: /\.css$/,
include: /node_modules\/(?!@parity)*/,
use: [ 'style-loader', 'css-loader' ]
},
{
test: /\.css$/,
exclude: /node_modules\/(?!@parity)*/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
localIdentName: '[name]_[local]_[hash:base64:10]',
minimize: true,
modules: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: (loader) => [
require('postcss-import'),
require('postcss-nested'),
require('postcss-simple-vars')
]
}
}
]
},
{
test: /\.(png|jpg)$/,
use: [ {
loader: 'file-loader',
options: {
name: 'assets/[name].[hash].[ext]'
}
} ]
},
{
test: /\.(woff|woff2|ttf|eot|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [ {
loader: 'file-loader',
options: {
name: 'fonts/[name][hash].[ext]'
}
} ]
},
{
test: /parity-logo-white-no-text\.svg/,
use: [ 'url-loader' ]
},
{
test: /\.svg(\?v=[0-9]\.[0-9]\.[0-9])?$/,
exclude: [ /parity-logo-white-no-text\.svg/ ],
use: [ {
loader: 'file-loader',
options: {
name: 'assets/[name].[hash].[ext]'
}
} ]
}
],
noParse: [
/node_modules\/sinon/
]
},
resolve: {
alias: {
'~': path.resolve(__dirname, '..'),
'@parity/abi': path.resolve(__dirname, '../node_modules/@parity/abi'),
'@parity/api': path.resolve(__dirname, '../node_modules/@parity/api'),
'@parity/etherscan': path.resolve(__dirname, '../node_modules/@parity/etherscan'),
'@parity/jsonrpc': path.resolve(__dirname, '../node_modules/@parity/jsonrpc'),
'@parity/parity.js': path.resolve(__dirname, '../node_modules/@parity/parity.js'),
'@parity/shared': path.resolve(__dirname, '../node_modules/@parity/shared'),
'@parity/ui': path.resolve(__dirname, '../node_modules/@parity/ui'),
'@parity/wordlist': path.resolve(__dirname, '../node_modules/@parity/wordlist'),
'@parity': path.resolve(__dirname, '../packages')
}, },
modules: [ {
path.join(__dirname, '../node_modules') test: /\.json$/,
], use: [ 'json-loader' ]
extensions: ['.json', '.js', '.jsx'], },
unsafeCache: true {
test: /\.ejs$/,
use: [ 'ejs-loader' ]
},
{
test: /\.html$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
},
'extract-loader',
{
loader: 'html-loader',
options: {
root: path.resolve(__dirname, '../assets/images'),
attrs: ['img:src', 'link:href']
}
}
]
},
{
test: /\.md$/,
use: [ 'html-loader', 'markdown-loader' ]
},
{
test: /\.css$/,
include: /node_modules\/(?!@parity)*/,
use: [ 'style-loader', 'css-loader' ]
},
{
test: /\.css$/,
exclude: /node_modules\/(?!@parity)*/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
localIdentName: '[name]_[local]_[hash:base64:10]',
minimize: true,
modules: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: (loader) => [
require('postcss-import'),
require('postcss-nested'),
require('postcss-simple-vars')
]
}
}
]
},
{
test: /\.(png|jpg)$/,
use: [ {
loader: 'file-loader',
options: {
name: 'assets/[name].[hash].[ext]'
}
} ]
},
{
test: /\.(woff|woff2|ttf|eot|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [ {
loader: 'file-loader',
options: {
name: 'fonts/[name][hash].[ext]'
}
} ]
},
{
test: /parity-logo-white-no-text\.svg/,
use: [ 'url-loader' ]
},
{
test: /\.svg(\?v=[0-9]\.[0-9]\.[0-9])?$/,
exclude: [ /parity-logo-white-no-text\.svg/ ],
use: [ {
loader: 'file-loader',
options: {
name: 'assets/[name].[hash].[ext]'
}
} ]
}
],
noParse: [
/node_modules\/sinon/
]
},
resolve: {
alias: {
'~': path.resolve(__dirname, '..')
}, },
modules: [
path.join(__dirname, '../node_modules')
],
extensions: ['.json', '.js', '.jsx'],
unsafeCache: true
},
node: { node: {
fs: 'empty' fs: 'empty'
}, },
plugins: (function () { plugins: (function () {
const DappsHTMLInjection = [] let plugins = Shared.getPlugins().concat(
.concat(DAPPS_BUILTIN, DAPPS_VIEWS) new WebpackErrorNotificationPlugin()
.filter((dapp) => !dapp.skipBuild) );
.map((dapp) => {
return new HtmlWebpackPlugin({
title: dapp.name,
filename: dapp.url + '.html',
template: '../packages/dapps/index.ejs',
favicon: FAVICON,
secure: dapp.secure,
chunks: [ dapp.url ]
});
});
let plugins = Shared.getPlugins().concat( if (!isEmbed) {
new WebpackErrorNotificationPlugin() plugins = [].concat(
plugins,
new HtmlWebpackPlugin({
title: 'Parity',
filename: 'index.html',
template: './index.ejs',
favicon: FAVICON,
chunks: [ 'index' ]
}),
new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname, '../src/serviceWorker.js')
}),
new CopyWebpackPlugin(
flatten([
{
from: './error_pages.css',
to: 'styles.css'
},
flatten(
DAPPS_ALL.map((dapp) => {
const destination = Api.util.isHex(dapp.id)
? dapp.id
: Api.util.sha3(dapp.url);
return [
{
from: `../node_modules/${dapp.package}/dist`,
to: `dapps/${destination}/dist/`
},
{
from: `../node_modules/${dapp.package}/index.html`,
to: `dapps/${destination}/`
}
];
})
)
]),
{}
)
); );
}
if (!isEmbed) { if (isEmbed) {
plugins = [].concat( plugins.push(
plugins, new HtmlWebpackPlugin({
title: 'Parity Bar',
filename: 'embed.html',
template: './index.ejs',
favicon: FAVICON,
chunks: [ 'embed' ]
})
);
}
new HtmlWebpackPlugin({ return plugins;
title: 'Parity', }())
filename: 'index.html', };
template: './index.ejs',
favicon: FAVICON,
chunks: [ 'index' ]
}),
new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname, '../src/serviceWorker.js')
}),
DappsHTMLInjection,
new CopyWebpackPlugin([
{ from: './error_pages.css', to: 'styles.css' },
{ from: '../packages/dapps/static' }
], {})
);
}
if (isEmbed) {
plugins.push(
new HtmlWebpackPlugin({
title: 'Parity Bar',
filename: 'embed.html',
template: './index.ejs',
favicon: FAVICON,
chunks: [ 'embed' ]
})
);
}
// if (!isAnalize && !isProd) {
// const DEST_I18N = path.join(__dirname, '..', DEST, 'i18n');
//
// plugins.push(
// new ReactIntlAggregatePlugin({
// messagesPattern: DEST_I18N + '/i18n/**/*.json',
// aggregateOutputDir: DEST_I18N + '/i18n/',
// aggregateFilename: 'en'
// })
// );
// }
return plugins;
}())
};
});

View File

@ -0,0 +1,35 @@
// Copyright 2015-2017 Parity Technologies (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/>.
// test only
/**
* Run `DAPPS_URL="/" PARITY_URL="127.0.0.1:8546" 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 Shared = require('./shared');
var app = express();
Shared.addProxies(app);
app.use(express.static('.build'));
var server = app.listen(process.env.PORT || 3000, function () {
console.log('Listening on port', server.address().port);
});

97
js/webpack/dev.server.js Normal file
View File

@ -0,0 +1,97 @@
// Copyright 2015-2017 Parity Technologies (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/>.
const webpack = require('webpack');
const WebpackStats = require('webpack/lib/Stats');
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 () {
webpackConfig.performance = { hints: false };
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.NoEmitOnErrorsPlugin());
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: true,
quiet: false,
progress: true,
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true
},
reporter: function (data) {
// @see https://github.com/webpack/webpack/blob/324d309107f00cfc38ec727521563d309339b2ec/lib/Stats.js#L790
// Accepted values: none, errors-only, minimal, normal, verbose
const options = WebpackStats.presetToOptions('minimal');
options.timings = true;
const output = data.stats.toString(options);
process.stdout.write('\n');
process.stdout.write(output);
process.stdout.write('\n\n');
}
}));
// Add the dev proxies in the express App
Shared.addProxies(app);
app.use(express.static(webpackConfig.output.path));
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 });
});

View File

@ -24,61 +24,53 @@ const Shared = require('./shared');
const DEST = process.env.BUILD_DEST || '.build'; const DEST = process.env.BUILD_DEST || '.build';
module.exports = ['inject', 'parity', 'web3'].map((entryName) => { module.exports = {
return { context: path.join(__dirname, '../src'),
context: path.join(__dirname, '../src'), entry: {
entry: { inject: ['./inject.js'],
[entryName]: ['./inject.js'] parity: ['./inject.js'],
}, web3: ['./inject.js']
output: { },
path: path.join(__dirname, '../', DEST), output: {
filename: '[name].js', path: path.join(__dirname, '../', DEST),
library: '[name].js', filename: '[name].js',
libraryTarget: 'umd' library: '[name].js',
}, libraryTarget: 'umd'
},
resolve: { resolve: {
alias: { alias: {
'~': path.resolve(__dirname, '..'), '~': path.resolve(__dirname, '..')
'@parity/abi': path.resolve(__dirname, '../node_modules/@parity/abi'), }
'@parity/api': path.resolve(__dirname, '../node_modules/@parity/api'), },
'@parity/etherscan': path.resolve(__dirname, '../node_modules/@parity/etherscan'),
'@parity/jsonrpc': path.resolve(__dirname, '../node_modules/@parity/jsonrpc'), node: {
'@parity/shared': path.resolve(__dirname, '../node_modules/@parity/shared'), fs: 'empty'
'@parity/ui': path.resolve(__dirname, '../node_modules/@parity/ui'), },
'@parity/wordlist': path.resolve(__dirname, '../node_modules/@parity/wordlist'),
'@parity': path.resolve(__dirname, '../packages') module: {
rules: [
rulesParity,
rulesEs6,
{
test: /\.js$/,
exclude: /node_modules/,
use: [ 'babel-loader' ]
},
{
test: /\.json$/,
use: [ 'json-loader' ]
},
{
test: /\.html$/,
use: [ {
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
} ]
} }
}, ]
},
node: { plugins: Shared.getPlugins()
fs: 'empty' };
},
module: {
rules: [
rulesParity,
rulesEs6,
{
test: /\.js$/,
exclude: /node_modules/,
use: [ 'babel-loader' ]
},
{
test: /\.json$/,
use: [ 'json-loader' ]
},
{
test: /\.html$/,
use: [ {
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
} ]
}
]
},
plugins: Shared.getPlugins()
};
});

View File

@ -115,23 +115,6 @@ function getPlugins (_isProd = isProd) {
return plugins; return plugins;
} }
function getDappsEntry () {
const builtins = require('@parity/shared/config/dappsBuiltin.json');
const views = require('@parity/shared/config/dappsViews.json');
return Object.assign(
[]
.concat(
builtins.filter((dapp) => !dapp.skipBuild),
views
)
.reduce((_entry, dapp) => {
_entry[dapp.url] = '../packages/dapp-' + dapp.url + '/index.js';
return _entry;
}, {})
);
}
function addProxies (app) { function addProxies (app) {
const proxy = require('http-proxy-middleware'); const proxy = require('http-proxy-middleware');
@ -166,6 +149,5 @@ function addProxies (app) {
module.exports = { module.exports = {
getBabelrc: getBabelrc, getBabelrc: getBabelrc,
getPlugins: getPlugins, getPlugins: getPlugins,
dappsEntry: getDappsEntry(),
addProxies: addProxies addProxies: addProxies
}; };