dashboard: improve development process

This commit is contained in:
Kurkó Mihály 2018-10-14 22:01:18 +03:00
parent 6566a0a3b8
commit f4244d9848
20 changed files with 2464 additions and 2480 deletions

1
.gitignore vendored
View file

@ -42,6 +42,7 @@ profile.cov
/dashboard/assets/node_modules /dashboard/assets/node_modules
/dashboard/assets/stats.json /dashboard/assets/stats.json
/dashboard/assets/bundle.js /dashboard/assets/bundle.js
/dashboard/assets/bundle.js.map
/dashboard/assets/package-lock.json /dashboard/assets/package-lock.json
**/yarn-error.log **/yarn-error.log

View file

@ -0,0 +1,3 @@
node_modules/* #ignored by default
flow-typed/*
bundle.js

View file

@ -16,71 +16,66 @@
// React syntax style mostly according to https://github.com/airbnb/javascript/tree/master/react // React syntax style mostly according to https://github.com/airbnb/javascript/tree/master/react
{ {
'env': { "env": {
'browser': true, "browser": true,
'node': true, "node": true,
'es6': true, "es6": true
}, },
'parser': 'babel-eslint', "parser": "babel-eslint",
'parserOptions': { "parserOptions": {
'sourceType': 'module', "sourceType": "module",
'ecmaVersion': 6, "ecmaVersion": 6,
'ecmaFeatures': { "ecmaFeatures": {
'jsx': true, "jsx": true
} }
}, },
'extends': 'airbnb', "extends": [
'plugins': [ "eslint:recommended",
'flowtype', "airbnb",
'react', "plugin:flowtype/recommended",
"plugin:react/recommended"
], ],
'rules': { "plugins": [
'no-tabs': 'off', "flowtype",
'indent': ['error', 'tab'], "react"
'react/jsx-indent': ['error', 'tab'], ],
'react/jsx-indent-props': ['error', 'tab'], "rules": {
'react/prefer-stateless-function': 'off', "no-tabs": "off",
'jsx-quotes': ['error', 'prefer-single'], "indent": ["error", "tab"],
'no-plusplus': 'off', "react/jsx-indent": ["error", "tab"],
'no-console': ['error', { allow: ['error'] }], "react/jsx-indent-props": ["error", "tab"],
"react/prefer-stateless-function": "off",
"react/destructuring-assignment": ["error", "always", {"ignoreClassFields": true}],
"jsx-quotes": ["error", "prefer-single"],
"no-plusplus": "off",
"no-console": ["error", { "allow": ["error"] }],
// Specifies the maximum length of a line. // Specifies the maximum length of a line.
'max-len': ['warn', 120, 2, { "max-len": ["warn", 120, 2, {
'ignoreUrls': true, "ignoreUrls": true,
'ignoreComments': false, "ignoreComments": false,
'ignoreRegExpLiterals': true, "ignoreRegExpLiterals": true,
'ignoreStrings': true, "ignoreStrings": true,
'ignoreTemplateLiterals': true, "ignoreTemplateLiterals": true
}], }],
// Enforces consistent spacing between keys and values in object literal properties. // Enforces consistent spacing between keys and values in object literal properties.
'key-spacing': ['error', {'align': { "key-spacing": ["error", {"align": {
'beforeColon': false, "beforeColon": false,
'afterColon': true, "afterColon": true,
'on': 'value' "on": "value"
}}], }}],
// Prohibits padding inside curly braces. // Prohibits padding inside curly braces.
'object-curly-spacing': ['error', 'never'], "object-curly-spacing": ["error", "never"],
'no-use-before-define': 'off', // messageAPI "no-use-before-define": "off", // message types
'default-case': 'off', "default-case": "off"
'flowtype/boolean-style': ['error', 'boolean'],
'flowtype/define-flow-type': 'warn',
'flowtype/generic-spacing': ['error', 'never'],
'flowtype/no-primitive-constructor-types': 'error',
'flowtype/no-weak-types': 'error',
'flowtype/object-type-delimiter': ['error', 'comma'],
'flowtype/require-valid-file-annotation': 'error',
'flowtype/semi': ['error', 'always'],
'flowtype/space-after-type-colon': ['error', 'always'],
'flowtype/space-before-generic-bracket': ['error', 'never'],
'flowtype/space-before-type-colon': ['error', 'never'],
'flowtype/union-intersection-spacing': ['error', 'always'],
'flowtype/use-flow-type': 'warn',
'flowtype/valid-syntax': 'warn',
}, },
'settings': { "settings": {
'flowtype': { "import/resolver": {
'onlyFilesWithFlowAnnotation': true, "node": {
"paths": ["components"] // import './components/Component' -> import 'Component'
} }
}, },
"flowtype": {
"onlyFilesWithFlowAnnotation": true
}
}
} }

View file

@ -7,3 +7,5 @@ node_modules/jss/flow-typed
[options] [options]
include_warnings=true include_warnings=true
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=components

View file

@ -19,7 +19,7 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import type {ChildrenArray} from 'react'; import type {ChildrenArray} from 'react';
import Grid from 'material-ui/Grid'; import Grid from '@material-ui/core/Grid';
// styles contains the constant styles of the component. // styles contains the constant styles of the component.
const styles = { const styles = {
@ -33,7 +33,7 @@ const styles = {
flex: 1, flex: 1,
padding: 0, padding: 0,
}, },
} };
export type Props = { export type Props = {
children: ChildrenArray<React$Element<any>>, children: ChildrenArray<React$Element<any>>,

View file

@ -18,7 +18,7 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import Typography from 'material-ui/Typography'; import Typography from '@material-ui/core/Typography';
import {styles} from '../common'; import {styles} from '../common';
// multiplier multiplies a number by another. // multiplier multiplies a number by another.
@ -70,7 +70,8 @@ export const bytePerSecPlotter = <T>(text: string, mapper: (T => T) = multiplier
} }
return ( return (
<Typography type='caption' color='inherit'> <Typography type='caption' color='inherit'>
<span style={styles.light}>{text}</span> {simplifyBytes(p)}/s <span style={styles.light}>{text}</span>
{simplifyBytes(p)}/s
</Typography> </Typography>
); );
}; };

View file

@ -17,14 +17,15 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
import React, {Component} from 'react'; import React, {Component} from 'react';
import {hot} from 'react-hot-loader';
import withStyles from 'material-ui/styles/withStyles'; import withStyles from '@material-ui/core/styles/withStyles';
import Header from './Header'; import Header from 'Header';
import Body from './Body'; import Body from 'Body';
import {inserter as logInserter, SAME} from 'Logs';
import {MENU} from '../common'; import {MENU} from '../common';
import type {Content} from '../types/content'; import type {Content} from '../types/content';
import {inserter as logInserter} from './Logs';
// deepUpdate updates an object corresponding to the given update data, which has // deepUpdate updates an object corresponding to the given update data, which has
// the shape of the same structure as the original object. updater also has the same // the shape of the same structure as the original object. updater also has the same
@ -37,7 +38,6 @@ import {inserter as logInserter} from './Logs';
// of the update. // of the update.
const deepUpdate = (updater: Object, update: Object, prev: Object): $Shape<Content> => { const deepUpdate = (updater: Object, update: Object, prev: Object): $Shape<Content> => {
if (typeof update === 'undefined') { if (typeof update === 'undefined') {
// TODO (kurkomisi): originally this was deep copy, investigate it.
return prev; return prev;
} }
if (typeof updater === 'function') { if (typeof updater === 'function') {
@ -103,8 +103,8 @@ const defaultContent: () => Content = () => ({
chunks: [], chunks: [],
endTop: false, endTop: false,
endBottom: true, endBottom: true,
topChanged: 0, topChanged: SAME,
bottomChanged: 0, bottomChanged: SAME,
}, },
}); });
@ -186,8 +186,8 @@ class Dashboard extends Component<Props, State> {
// reconnect establishes a websocket connection with the server, listens for incoming messages // reconnect establishes a websocket connection with the server, listens for incoming messages
// and tries to reconnect on connection loss. // and tries to reconnect on connection loss.
reconnect = () => { reconnect = () => {
// PROD is defined by webpack. const host = process.env.NODE_ENV === 'production' ? window.location.host : 'localhost:8080';
const server = new WebSocket(`${((window.location.protocol === 'https:') ? 'wss://' : 'ws://')}${PROD ? window.location.host : 'localhost:8080'}/api`); const server = new WebSocket(`${((window.location.protocol === 'https:') ? 'wss://' : 'ws://')}${host}/api`);
server.onopen = () => { server.onopen = () => {
this.setState({content: defaultContent(), shouldUpdate: {}, server}); this.setState({content: defaultContent(), shouldUpdate: {}, server});
}; };
@ -249,4 +249,4 @@ class Dashboard extends Component<Props, State> {
} }
} }
export default withStyles(themeStyles)(Dashboard); export default hot(module)(withStyles(themeStyles)(Dashboard));

View file

@ -18,13 +18,16 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import withStyles from 'material-ui/styles/withStyles'; import withStyles from '@material-ui/core/styles/withStyles';
import Typography from 'material-ui/Typography'; import Typography from '@material-ui/core/Typography';
import Grid from 'material-ui/Grid'; import Grid from '@material-ui/core/Grid';
import {ResponsiveContainer, AreaChart, Area, Tooltip} from 'recharts'; import ResponsiveContainer from 'recharts/es6/component/ResponsiveContainer';
import AreaChart from 'recharts/es6/chart/AreaChart';
import Area from 'recharts/es6/cartesian/Area';
import Tooltip from 'recharts/es6/component/Tooltip';
import ChartRow from './ChartRow'; import ChartRow from 'ChartRow';
import CustomTooltip, {bytePlotter, bytePerSecPlotter, percentPlotter, multiplier} from './CustomTooltip'; import CustomTooltip, {bytePlotter, bytePerSecPlotter, percentPlotter, multiplier} from 'CustomTooltip';
import {styles as commonStyles} from '../common'; import {styles as commonStyles} from '../common';
import type {General, System} from '../types/content'; import type {General, System} from '../types/content';
@ -53,6 +56,10 @@ const styles = {
height: '100%', height: '100%',
width: '99%', width: '99%',
}, },
link: {
color: 'inherit',
textDecoration: 'none',
},
}; };
// themeStyles returns the styles generated from the theme for the component. // themeStyles returns the styles generated from the theme for the component.
@ -73,16 +80,18 @@ export type Props = {
shouldUpdate: Object, shouldUpdate: Object,
}; };
type State = {};
// Footer renders the footer of the dashboard. // Footer renders the footer of the dashboard.
class Footer extends Component<Props> { class Footer extends Component<Props, State> {
shouldComponentUpdate(nextProps) { shouldComponentUpdate(nextProps: Readonly<Props>, nextState: Readonly<State>, nextContext: any) {
return typeof nextProps.shouldUpdate.general !== 'undefined' || typeof nextProps.shouldUpdate.system !== 'undefined'; return typeof nextProps.shouldUpdate.general !== 'undefined' || typeof nextProps.shouldUpdate.system !== 'undefined';
} }
// halfHeightChart renders an area chart with half of the height of its parent. // halfHeightChart renders an area chart with half of the height of its parent.
halfHeightChart = (chartProps, tooltip, areaProps) => ( halfHeightChart = (chartProps, tooltip, areaProps) => (
<ResponsiveContainer width='100%' height='50%'> <ResponsiveContainer width='100%' height='50%'>
<AreaChart {...chartProps} > <AreaChart {...chartProps}>
{!tooltip || (<Tooltip cursor={false} content={<CustomTooltip tooltip={tooltip} />} />)} {!tooltip || (<Tooltip cursor={false} content={<CustomTooltip tooltip={tooltip} />} />)}
<Area isAnimationActive={false} type='monotone' {...areaProps} /> <Area isAnimationActive={false} type='monotone' {...areaProps} />
</AreaChart> </AreaChart>
@ -158,14 +167,19 @@ class Footer extends Component<Props> {
)} )}
</ChartRow> </ChartRow>
</Grid> </Grid>
<Grid item > <Grid item>
<Typography type='caption' color='inherit'> <Typography type='caption' color='inherit'>
<span style={commonStyles.light}>Geth</span> {general.version} <span style={commonStyles.light}>Geth</span> {general.version}
</Typography> </Typography>
{general.commit && ( {general.commit && (
<Typography type='caption' color='inherit'> <Typography type='caption' color='inherit'>
<span style={commonStyles.light}>{'Commit '}</span> <span style={commonStyles.light}>{'Commit '}</span>
<a href={`https://github.com/ethereum/go-ethereum/commit/${general.commit}`} target='_blank' style={{color: 'inherit', textDecoration: 'none'}} > <a
href={`https://github.com/ethereum/go-ethereum/commit/${general.commit}`}
target='_blank'
rel='noopener noreferrer'
style={styles.link}
>
{general.commit.substring(0, 8)} {general.commit.substring(0, 8)}
</a> </a>
</Typography> </Typography>

View file

@ -18,13 +18,13 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import withStyles from 'material-ui/styles/withStyles'; import withStyles from '@material-ui/core/styles/withStyles';
import AppBar from 'material-ui/AppBar'; import AppBar from '@material-ui/core/AppBar';
import Toolbar from 'material-ui/Toolbar'; import Toolbar from '@material-ui/core/Toolbar';
import IconButton from 'material-ui/IconButton'; import IconButton from '@material-ui/core/IconButton';
import Icon from 'material-ui/Icon'; import Icon from '@material-ui/core/Icon';
import MenuIcon from 'material-ui-icons/Menu'; import MenuIcon from '@material-ui/icons/Menu';
import Typography from 'material-ui/Typography'; import Typography from '@material-ui/core/Typography';
// styles contains the constant styles of the component. // styles contains the constant styles of the component.
const styles = { const styles = {

View file

@ -18,7 +18,8 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import List, {ListItem} from 'material-ui/List'; import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import escapeHtml from 'escape-html'; import escapeHtml from 'escape-html';
import type {Record, Content, LogsMessage, Logs as LogsType} from '../types/content'; import type {Record, Content, LogsMessage, Logs as LogsType} from '../types/content';
@ -104,9 +105,9 @@ const createChunk = (records: Array<Record>) => {
// ADDED, SAME and REMOVED are used to track the change of the log chunk array. // ADDED, SAME and REMOVED are used to track the change of the log chunk array.
// The scroll position is set using these values. // The scroll position is set using these values.
const ADDED = 1; export const ADDED = 1;
const SAME = 0; export const SAME = 0;
const REMOVED = -1; export const REMOVED = -1;
// inserter is a state updater function for the main component, which inserts the new log chunk into the chunk array. // inserter is a state updater function for the main component, which inserts the new log chunk into the chunk array.
// limit is the maximum length of the chunk array, used in order to prevent the browser from OOM. // limit is the maximum length of the chunk array, used in order to prevent the browser from OOM.
@ -251,15 +252,15 @@ class Logs extends Component<Props, State> {
// atBottom checks if the scroll position it at the bottom of the container. // atBottom checks if the scroll position it at the bottom of the container.
atBottom = () => { atBottom = () => {
const {container} = this.props; const {container} = this.props;
return container.scrollHeight - container.scrollTop <= return container.scrollHeight - container.scrollTop
container.clientHeight + container.scrollHeight * requestBand; <= container.clientHeight + container.scrollHeight * requestBand;
}; };
// beforeUpdate is called by the parent component, saves the previous scroll position // beforeUpdate is called by the parent component, saves the previous scroll position
// and the height of the first log chunk, which can be deleted during the insertion. // and the height of the first log chunk, which can be deleted during the insertion.
beforeUpdate = () => { beforeUpdate = () => {
let firstHeight = 0; let firstHeight = 0;
let chunkList = this.content.children[1]; const chunkList = this.content.children[1];
if (chunkList && chunkList.children[0]) { if (chunkList && chunkList.children[0]) {
firstHeight = chunkList.children[0].clientHeight; firstHeight = chunkList.children[0].clientHeight;
} }

View file

@ -18,11 +18,11 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import withStyles from 'material-ui/styles/withStyles'; import withStyles from '@material-ui/core/styles/withStyles';
import Logs from 'Logs';
import Footer from 'Footer';
import {MENU} from '../common'; import {MENU} from '../common';
import Logs from './Logs';
import Footer from './Footer';
import type {Content} from '../types/content'; import type {Content} from '../types/content';
// styles contains the constant styles of the component. // styles contains the constant styles of the component.
@ -54,21 +54,16 @@ export type Props = {
send: string => void, send: string => void,
}; };
type State = {};
// Main renders the chosen content. // Main renders the chosen content.
class Main extends Component<Props> { class Main extends Component<Props, State> {
constructor(props) { constructor(props) {
super(props); super(props);
this.container = React.createRef(); this.container = React.createRef();
this.content = React.createRef(); this.content = React.createRef();
} }
getSnapshotBeforeUpdate() {
if (this.content && typeof this.content.beforeUpdate === 'function') {
return this.content.beforeUpdate();
}
return null;
}
componentDidUpdate(prevProps, prevState, snapshot) { componentDidUpdate(prevProps, prevState, snapshot) {
if (this.content && typeof this.content.didUpdate === 'function') { if (this.content && typeof this.content.didUpdate === 'function') {
this.content.didUpdate(prevProps, prevState, snapshot); this.content.didUpdate(prevProps, prevState, snapshot);
@ -81,6 +76,13 @@ class Main extends Component<Props> {
} }
}; };
getSnapshotBeforeUpdate(prevProps: Readonly<P>, prevState: Readonly<S>) {
if (this.content && typeof this.content.beforeUpdate === 'function') {
return this.content.beforeUpdate();
}
return null;
}
render() { render() {
const { const {
classes, active, content, shouldUpdate, classes, active, content, shouldUpdate,
@ -89,9 +91,17 @@ class Main extends Component<Props> {
let children = null; let children = null;
switch (active) { switch (active) {
case MENU.get('home').id: case MENU.get('home').id:
children = <div>Work in progress.</div>;
break;
case MENU.get('chain').id: case MENU.get('chain').id:
children = <div>Work in progress.</div>;
break;
case MENU.get('txpool').id: case MENU.get('txpool').id:
children = <div>Work in progress.</div>;
break;
case MENU.get('network').id: case MENU.get('network').id:
children = <Network content={this.props.content.network} />;
break;
case MENU.get('system').id: case MENU.get('system').id:
children = <div>Work in progress.</div>; children = <div>Work in progress.</div>;
break; break;

View file

@ -18,9 +18,12 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import withStyles from 'material-ui/styles/withStyles'; import withStyles from '@material-ui/core/styles/withStyles';
import List, {ListItem, ListItemIcon, ListItemText} from 'material-ui/List'; import List from '@material-ui/core/List';
import Icon from 'material-ui/Icon'; import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import Icon from '@material-ui/core/Icon';
import Transition from 'react-transition-group/Transition'; import Transition from 'react-transition-group/Transition';
import {Icon as FontAwesome} from 'react-fa'; import {Icon as FontAwesome} from 'react-fa';
@ -48,6 +51,7 @@ const themeStyles = theme => ({
}, },
icon: { icon: {
fontSize: theme.spacing.unit * 3, fontSize: theme.spacing.unit * 3,
overflow: 'unset',
}, },
}); });
@ -57,9 +61,11 @@ export type Props = {
changeContent: string => void, changeContent: string => void,
}; };
type State = {}
// SideBar renders the sidebar of the dashboard. // SideBar renders the sidebar of the dashboard.
class SideBar extends Component<Props> { class SideBar extends Component<Props, State> {
shouldComponentUpdate(nextProps) { shouldComponentUpdate(nextProps: Readonly<Props>, nextState: Readonly<State>, nextContext: any) {
return nextProps.opened !== this.props.opened; return nextProps.opened !== this.props.opened;
} }

View file

@ -16,10 +16,9 @@
// fa-only-woff-loader removes the .eot, .ttf, .svg dependencies of the FontAwesome library, // fa-only-woff-loader removes the .eot, .ttf, .svg dependencies of the FontAwesome library,
// because they produce unused extra blobs. // because they produce unused extra blobs.
module.exports = function(content) { module.exports = content => content
return content .replace(/src.*url(?!.*url.*(\.eot)).*(\.eot)[^;]*;/, '')
.replace(/src.*url(?!.*url.*(\.eot)).*(\.eot)[^;]*;/,'') .replace(/url(?!.*url.*(\.eot)).*(\.eot)[^,]*,/, '')
.replace(/url(?!.*url.*(\.eot)).*(\.eot)[^,]*,/,'') .replace(/url(?!.*url.*(\.ttf)).*(\.ttf)[^,]*,/, '')
.replace(/url(?!.*url.*(\.ttf)).*(\.ttf)[^,]*,/,'') .replace(/,[^,]*url(?!.*url.*(\.svg)).*(\.svg)[^;]*;/, ';');
.replace(/,[^,]*url(?!.*url.*(\.svg)).*(\.svg)[^;]*;/,';');
};

View file

@ -21,6 +21,6 @@
</head> </head>
<body style="height: 100%; margin: 0"> <body style="height: 100%; margin: 0">
<div id="dashboard" style="height: 100%"></div> <div id="dashboard" style="height: 100%"></div>
<script src="bundle.js"></script> <script type="text/javascript" src="bundle.js"></script>
</body> </body>
</html> </html>

View file

@ -19,8 +19,8 @@
import React from 'react'; import React from 'react';
import {render} from 'react-dom'; import {render} from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import MuiThemeProvider from '@material-ui/core/styles/MuiThemeProvider';
import createMuiTheme from 'material-ui/styles/createMuiTheme'; import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
import Dashboard from './components/Dashboard'; import Dashboard from './components/Dashboard';

View file

@ -1,48 +1,57 @@
{ {
"private": true,
"dependencies": { "dependencies": {
"babel-core": "^6.26.0", "@babel/core": "7.1.2",
"babel-eslint": "^8.2.1", "@babel/plugin-proposal-class-properties": "7.1.0",
"babel-loader": "^7.1.2", "@babel/plugin-proposal-function-bind": "^7.0.0",
"babel-plugin-transform-class-properties": "^6.24.1", "@babel/plugin-transform-flow-strip-types": "^7.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4", "@babel/preset-env": "7.1.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0", "@babel/preset-react": "^7.0.0",
"babel-plugin-transform-runtime": "^6.23.0", "@babel/preset-stage-0": "^7.0.0",
"babel-preset-env": "^1.6.1", "@material-ui/core": "3.2.0",
"babel-preset-react": "^6.24.1", "@material-ui/icons": "^3.0.1",
"babel-preset-stage-0": "^6.24.1", "babel-eslint": "10.0.1",
"babel-runtime": "^6.26.0", "babel-loader": "8.0.4",
"classnames": "^2.2.5", "classnames": "^2.2.6",
"css-loader": "^0.28.9", "css-loader": "^1.0.0",
"escape-html": "^1.0.3", "escape-html": "^1.0.3",
"eslint": "^4.16.0", "eslint": "5.7.0",
"eslint-config-airbnb": "^16.1.0", "eslint-config-airbnb": "^17.0.0",
"eslint-loader": "^2.0.0", "eslint-loader": "2.1.1",
"eslint-plugin-flowtype": "^2.41.0", "eslint-plugin-flowtype": "3.0.0",
"eslint-plugin-import": "^2.8.0", "eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-react": "^7.5.1", "eslint-plugin-node": "^7.0.1",
"file-loader": "^1.1.6", "eslint-plugin-promise": "4.0.1",
"flow-bin": "^0.63.1", "eslint-plugin-react": "7.11.1",
"flow-bin-loader": "^1.0.2", "file-loader": "2.0.0",
"flow-typed": "^2.2.3", "flow-bin": "0.83.0",
"material-ui": "^1.0.0-beta.30", "flow-bin-loader": "^1.0.3",
"material-ui-icons": "^1.0.0-beta.17", "flow-typed": "^2.5.1",
"path": "^0.12.7", "path": "^0.12.7",
"react": "^16.2.0", "react": "16.5.2",
"react-dom": "^16.2.0", "react-dom": "16.5.2",
"react-fa": "^5.0.0", "react-fa": "^5.0.0",
"react-transition-group": "^2.2.1", "react-hot-loader": "4.3.11",
"recharts": "^1.0.0-beta.9", "react-transition-group": "2.5.0",
"style-loader": "^0.19.1", "recharts": "1.3.4",
"style-loader": "0.23.1",
"uglifyjs-webpack-plugin": "2.0.1",
"url": "^0.11.0", "url": "^0.11.0",
"url-loader": "^0.6.2", "url-loader": "1.1.2",
"webpack": "^3.10.0", "webpack": "4.20.2",
"webpack-dev-server": "^2.11.1" "webpack-cli": "3.1.2",
"webpack-dev-server": "3.1.9",
"webpack-merge": "^4.1.4"
}, },
"scripts": { "scripts": {
"build": "NODE_ENV=production webpack", "build": "webpack --config webpack.config.prod.js",
"stats": "webpack --profile --json > stats.json", "stats": "webpack --config webpack.config.prod.js --profile --json > stats.json",
"dev": "webpack-dev-server --port 8081", "dev": "webpack-dev-server --open --config webpack.config.dev.js",
"flow": "flow-typed install" "install-flow": "flow-typed install",
} "flow": "flow status --show-all-errors",
"eslint": "eslint **/*"
},
"sideEffects": false,
"license": "LGPL-3.0-or-later"
} }

View file

@ -1,4 +1,4 @@
// Copyright 2017 The go-ethereum Authors // Copyright 2018 The go-ethereum Authors
// This file is part of the go-ethereum library. // This file is part of the go-ethereum library.
// //
// The go-ethereum library is free software: you can redistribute it and/or modify // The go-ethereum library is free software: you can redistribute it and/or modify
@ -14,28 +14,25 @@
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
const webpack = require('webpack');
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
target: 'web',
entry: {
bundle: './index',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, ''),
sourceMapFilename: '[file].map',
},
resolve: { resolve: {
modules: [
'node_modules',
path.resolve(__dirname, 'components'), // import './components/Component' -> import 'Component'
],
extensions: ['.js', '.jsx'], extensions: ['.js', '.jsx'],
}, },
entry: './index',
output: {
path: path.resolve(__dirname, ''),
filename: 'bundle.js',
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
comments: false,
mangle: false,
beautify: true,
}),
new webpack.DefinePlugin({
PROD: process.env.NODE_ENV === 'production',
}),
],
module: { module: {
rules: [ rules: [
{ {
@ -45,29 +42,40 @@ module.exports = {
{ {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
plugins: [ // order: from top to bottom
// 'transform-decorators-legacy', // @withStyles, @withTheme
'transform-class-properties', // static defaultProps
'transform-flow-strip-types',
],
presets: [ // order: from bottom to top presets: [ // order: from bottom to top
'env', '@babel/env',
'react', '@babel/react',
'stage-0', ],
plugins: [ // order: from top to bottom
'@babel/proposal-function-bind', // instead of stage 0
'@babel/proposal-class-properties', // static defaultProps
'@babel/transform-flow-strip-types',
'react-hot-loader/babel',
], ],
}, },
}, },
// 'eslint-loader', // show errors not only in the editor, but also in the console // 'eslint-loader', // show errors in the console
], ],
}, },
{ {
test: /font-awesome\.css$/, test: /\.css$/,
oneOf: [
{
test: /font-awesome/,
use: [ use: [
'style-loader', 'style-loader',
'css-loader', 'css-loader',
path.resolve(__dirname, './fa-only-woff-loader.js'), path.resolve(__dirname, './fa-only-woff-loader.js'),
], ],
}, },
{
use: [
'style-loader',
'css-loader',
],
},
],
},
{ {
test: /\.woff2?$/, // font-awesome icons test: /\.woff2?$/, // font-awesome icons
use: 'url-loader', use: 'url-loader',

View file

@ -0,0 +1,33 @@
// Copyright 2018 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.config.common.js');
module.exports = merge(common, {
mode: 'development',
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
// devtool: 'eval',
devtool: 'source-map',
devServer: {
port: 8081,
hot: true,
compress: true,
},
});

View file

@ -0,0 +1,41 @@
// Copyright 2018 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const merge = require('webpack-merge');
const common = require('./webpack.config.common.js');
module.exports = merge(common, {
mode: 'production',
devtool: 'nosources-source-map',
optimization: {
minimize: true,
namedModules: true, // Module names instead of numbers - resolves the large diff problem.
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
compress: true,
output: {
comments: false,
beautify: true,
},
// warnings: true,
},
sourceMap: true,
}),
],
},
});

File diff suppressed because it is too large Load diff