diff --git a/package.json b/package.json index e627a418..ef1faf11 100644 --- a/package.json +++ b/package.json @@ -11,16 +11,18 @@ }, "license": "LGPL-3.0+", "scripts": { - "dev": "webpack-dev-server --config ./webpack/config.dev.babel.js --mode development", - "dev:local": "webpack-dev-server --config ./webpack/config.dev.local.babel.js --mode development", - "build": "rm -rf build && webpack --config ./webpack/config.prod.babel.js --progress", + "dev": "npx webpack-dev-server --config ./webpack/dev.babel.js", + "dev:local": "npx webpack-dev-server --config ./webpack/local.babel.js", + "build:clean": "rm -rf build", + "build:production": "npx webpack --config ./webpack/production.babel.js --progress --bail", + "build": "run-s build:*", "flow": "flow check src", "lint": "run-s lint:*", - "lint:js": "eslint ./src ./webpack", - "lint:css": "stylelint './src/**/*.js'", + "lint:js": "npx eslint ./src ./webpack", + "lint:css": "npx stylelint './src/**/*.js'", "test": "run-s test:*", - "test:unit": "jest", - "test-unit:watch": "jest -o --watch" + "test:unit": "npx jest", + "test-unit:watch": "npx jest -o --watch" }, "dependencies": { "babel": "^6.23.0", diff --git a/src/assets/tos.pdf b/public/assets/tos.pdf similarity index 100% rename from src/assets/tos.pdf rename to public/assets/tos.pdf diff --git a/src/data/ERC20Abi.json b/public/data/ERC20Abi.json similarity index 100% rename from src/data/ERC20Abi.json rename to public/data/ERC20Abi.json diff --git a/src/data/appConfig.json b/public/data/appConfig.json similarity index 100% rename from src/data/appConfig.json rename to public/data/appConfig.json diff --git a/src/data/ethereumClassicTokens.json b/public/data/ethereumClassicTokens.json similarity index 100% rename from src/data/ethereumClassicTokens.json rename to public/data/ethereumClassicTokens.json diff --git a/src/data/ethereumTokens.json b/public/data/ethereumTokens.json similarity index 100% rename from src/data/ethereumTokens.json rename to public/data/ethereumTokens.json diff --git a/src/data/rinkebyTokens.json b/public/data/rinkebyTokens.json similarity index 100% rename from src/data/rinkebyTokens.json rename to public/data/rinkebyTokens.json diff --git a/src/data/ropstenTokens.json b/public/data/ropstenTokens.json similarity index 100% rename from src/data/ropstenTokens.json rename to public/data/ropstenTokens.json diff --git a/src/solidity/erc20.json b/public/solidity/erc20.json similarity index 100% rename from src/solidity/erc20.json rename to public/solidity/erc20.json diff --git a/src/solidity/grzegorz-token.js b/public/solidity/grzegorz-token.js similarity index 100% rename from src/solidity/grzegorz-token.js rename to public/solidity/grzegorz-token.js diff --git a/src/solidity/lahodka-token.js b/public/solidity/lahodka-token.js similarity index 100% rename from src/solidity/lahodka-token.js rename to public/solidity/lahodka-token.js diff --git a/src/solidity/rinkeby-token.js b/public/solidity/rinkeby-token.js similarity index 100% rename from src/solidity/rinkeby-token.js rename to public/solidity/rinkeby-token.js diff --git a/src/solidity/test-token.js b/public/solidity/test-token.js similarity index 100% rename from src/solidity/test-token.js rename to public/solidity/test-token.js diff --git a/src/actions/LocalStorageActions.js b/src/actions/LocalStorageActions.js index a434af9a..1cce5ca9 100644 --- a/src/actions/LocalStorageActions.js +++ b/src/actions/LocalStorageActions.js @@ -14,8 +14,8 @@ import type { } from 'flowtype'; import type { Config, Coin, TokensCollection } from 'reducers/LocalStorageReducer'; -import AppConfigJSON from 'data/appConfig.json'; -import Erc20AbiJSON from 'data/ERC20Abi.json'; +import Erc20AbiJSON from 'public/data/ERC20Abi.json'; +import AppConfigJSON from 'public/data/appConfig.json'; export type StorageAction = { type: typeof STORAGE.READY, diff --git a/src/components/Footer/index.js b/src/components/Footer/index.js index 602ba777..fa695d98 100644 --- a/src/components/Footer/index.js +++ b/src/components/Footer/index.js @@ -31,7 +31,7 @@ const Footer = ({ toggle }) => ( © {getYear(new Date())} SatoshiLabs - Terms + Terms Show Log ); diff --git a/webpack/constants.js b/webpack/constants.js index c3728102..51e911d6 100644 --- a/webpack/constants.js +++ b/webpack/constants.js @@ -6,6 +6,7 @@ export const ABSOLUTE_BASE: string = path.normalize(path.join(__dirname, '..')); const constants: Object = Object.freeze({ BUILD: path.join(ABSOLUTE_BASE, 'build/'), + PUBLIC: path.join(ABSOLUTE_BASE, 'public/'), SRC: path.join(ABSOLUTE_BASE, 'src/'), PORT: 8081, INDEX: path.join(ABSOLUTE_BASE, 'src/index.html'), @@ -24,5 +25,6 @@ export const BUILD: string = constants.BUILD; export const SRC: string = constants.SRC; export const PORT: string = constants.PORT; export const INDEX: string = constants.INDEX; +export const PUBLIC: string = constants.PUBLIC; export default constants; \ No newline at end of file diff --git a/webpack/config.dev.babel.js b/webpack/dev.babel.js similarity index 92% rename from webpack/config.dev.babel.js rename to webpack/dev.babel.js index 682b4ef7..7332cf8d 100644 --- a/webpack/config.dev.babel.js +++ b/webpack/dev.babel.js @@ -1,7 +1,9 @@ import webpack from 'webpack'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin'; -import { SRC, BUILD, PORT } from './constants'; +import { + SRC, BUILD, PORT, PUBLIC, +} from './constants'; module.exports = { watch: true, @@ -15,7 +17,10 @@ module.exports = { path: BUILD, }, devServer: { - contentBase: SRC, + contentBase: [ + SRC, + PUBLIC, + ], hot: true, https: false, port: PORT, @@ -69,6 +74,9 @@ module.exports = { ], }, resolve: { + alias: { + public: PUBLIC, + }, modules: [SRC, 'node_modules'], }, performance: { diff --git a/webpack/config.dev.local.babel.js b/webpack/local.babel.js similarity index 95% rename from webpack/config.dev.local.babel.js rename to webpack/local.babel.js index cf0be8ff..4ed1c6c2 100644 --- a/webpack/config.dev.local.babel.js +++ b/webpack/local.babel.js @@ -9,6 +9,7 @@ import { TREZOR_CONNECT, TREZOR_IFRAME, TREZOR_POPUP, TREZOR_WEBUSB, SRC, BUILD, + PUBLIC, PORT, } from './constants'; @@ -30,7 +31,10 @@ module.exports = { globalObject: 'this', // fix for HMR inside WebWorker from 'hd-wallet' }, devServer: { - contentBase: SRC, + contentBase: [ + SRC, + PUBLIC, + ], hot: true, https: false, port: PORT, @@ -92,8 +96,12 @@ module.exports = { ], }, resolve: { - modules: [SRC, 'node_modules', `${TREZOR_CONNECT_ROOT}/node_modules`], + modules: [ + SRC, + 'node_modules', + `${TREZOR_CONNECT_ROOT}/node_modules`], alias: { + public: PUBLIC, 'trezor-connect': `${TREZOR_CONNECT}`, }, }, diff --git a/webpack/config.prod.babel.js b/webpack/production.babel.js similarity index 87% rename from webpack/config.prod.babel.js rename to webpack/production.babel.js index 2eb7e07f..5cd2486a 100644 --- a/webpack/config.prod.babel.js +++ b/webpack/production.babel.js @@ -3,7 +3,7 @@ import webpack from 'webpack'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import CopyWebpackPlugin from 'copy-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin'; -import { SRC, BUILD } from './constants'; +import { SRC, BUILD, PUBLIC } from './constants'; module.exports = { mode: 'production', @@ -73,6 +73,9 @@ module.exports = { ], }, resolve: { + alias: { + public: PUBLIC, + }, modules: [SRC, 'node_modules'], }, performance: { @@ -82,22 +85,15 @@ module.exports = { new MiniCssExtractPlugin({ filename: 'css/[name].[hash].css', }), - new HtmlWebpackPlugin({ chunks: ['index'], template: `${SRC}index.html`, filename: 'index.html', inject: true, }), - new CopyWebpackPlugin([ - //{from: `${SRC}/app/robots.txt`}, - { from: `${SRC}images/favicon.ico`, to: `${BUILD}favicon.ico` }, - { from: `${SRC}images/favicon.png`, to: `${BUILD}favicon.png` }, - { from: `${SRC}data`, to: `${BUILD}data`, cache: false }, - { from: `${SRC}assets`, to: `${BUILD}assets`, cache: false }, + { from: `${PUBLIC}`, to: './' }, ]), - new webpack.optimize.OccurrenceOrderPlugin(), new webpack.NoEmitOnErrorsPlugin(), new webpack.NamedModulesPlugin(),