mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-26 16:01:29 +00:00
added webpack dev:local configuration
This commit is contained in:
parent
d7f8571974
commit
578fb736f5
@ -16,6 +16,7 @@
|
||||
"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",
|
||||
"flow": "flow check src/js",
|
||||
"lint": "npx eslint ./src ./webpack",
|
||||
@ -53,7 +54,7 @@
|
||||
"redux-raven-middleware": "^1.2.0",
|
||||
"redux-thunk": "^2.2.0",
|
||||
"styled-components": "^3.3.3",
|
||||
"trezor-connect": "5.0.13",
|
||||
"trezor-connect": "^5.0.28",
|
||||
"web3": "^0.19.0",
|
||||
"webpack": "^4.16.3",
|
||||
"whatwg-fetch": "^2.0.4",
|
||||
|
164
webpack/config.dev.local.babel.js
Normal file
164
webpack/config.dev.local.babel.js
Normal file
@ -0,0 +1,164 @@
|
||||
import {
|
||||
TREZOR_CONNECT_ROOT,
|
||||
TREZOR_CONNECT_HTML,
|
||||
TREZOR_CONNECT_FILES,
|
||||
TREZOR_CONNECT, TREZOR_IFRAME, TREZOR_POPUP, TREZOR_WEBUSB,
|
||||
SRC,
|
||||
BUILD,
|
||||
PORT
|
||||
} from './constants';
|
||||
|
||||
|
||||
import webpack from 'webpack';
|
||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
||||
|
||||
module.exports = {
|
||||
watch: true,
|
||||
mode: 'development',
|
||||
devtool: 'inline-source-map',
|
||||
entry: {
|
||||
'index': ['react-hot-loader/patch', `${SRC}js/index.js`],
|
||||
'trezor-connect-npm': `${TREZOR_CONNECT}.js`,
|
||||
// 'extension-permissions': `${TREZOR_CONNECT_ROOT}src/js/extensionPermissions.js`,
|
||||
'iframe': TREZOR_IFRAME,
|
||||
'popup': TREZOR_POPUP,
|
||||
'webusb': TREZOR_WEBUSB,
|
||||
},
|
||||
output: {
|
||||
filename: '[name].[hash].js',
|
||||
path: BUILD,
|
||||
globalObject: 'this', // fix for HMR inside WebWorker from 'hd-wallet'
|
||||
},
|
||||
devServer: {
|
||||
contentBase: SRC,
|
||||
hot: true,
|
||||
https: false,
|
||||
port: PORT,
|
||||
stats: 'minimal',
|
||||
inline: true,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
exclude: /node_modules/,
|
||||
use: ['babel-loader']
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: [
|
||||
{
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
options: { publicPath: '../' }
|
||||
},
|
||||
'css-loader',
|
||||
'less-loader',
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.(png|gif|jpg)$/,
|
||||
loader: 'file-loader?name=./images/[name].[ext]',
|
||||
query: {
|
||||
outputPath: './images',
|
||||
name: '[name].[ext]',
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.(ttf|eot|svg|woff|woff2)$/,
|
||||
loader: 'file-loader',
|
||||
query: {
|
||||
outputPath: './fonts',
|
||||
name: '[name].[ext]',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'javascript/auto',
|
||||
test: /\.json/,
|
||||
exclude: /(node_modules)/,
|
||||
loader: 'file-loader',
|
||||
query: {
|
||||
outputPath: './data',
|
||||
name: '[name].[ext]',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'javascript/auto',
|
||||
test: /\.wasm$/,
|
||||
loader: 'file-loader',
|
||||
query: {
|
||||
name: 'js/[name].[ext]',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
modules: [SRC, 'node_modules', `${TREZOR_CONNECT_ROOT}/node_modules`],
|
||||
alias: {
|
||||
'trezor-connect': `${TREZOR_CONNECT}`
|
||||
}
|
||||
},
|
||||
performance: {
|
||||
hints: false
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: '[name].css',
|
||||
chunkFilename: '[id].css',
|
||||
}),
|
||||
|
||||
new HtmlWebpackPlugin({
|
||||
chunks: ['index'],
|
||||
template: `${SRC}index.html`,
|
||||
filename: 'index.html',
|
||||
inject: true
|
||||
}),
|
||||
|
||||
new HtmlWebpackPlugin({
|
||||
chunks: ['iframe'],
|
||||
filename: `iframe.html`,
|
||||
template: `${TREZOR_CONNECT_HTML}iframe.html`,
|
||||
inject: false
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
chunks: ['popup'],
|
||||
filename: 'popup.html',
|
||||
template: `${TREZOR_CONNECT_HTML}popup.html`,
|
||||
inject: false
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
chunks: ['webusb'],
|
||||
filename: `webusb.html`,
|
||||
template: `${TREZOR_CONNECT_HTML}webusb.html`,
|
||||
inject: true
|
||||
}),
|
||||
// new HtmlWebpackPlugin({
|
||||
// chunks: ['extension-permissions'],
|
||||
// filename: `extension-permissions.html`,
|
||||
// template: `${TREZOR_CONNECT_HTML}extension-permissions.html`,
|
||||
// inject: true
|
||||
// }),
|
||||
|
||||
new CopyWebpackPlugin([
|
||||
{ from: TREZOR_CONNECT_FILES, to: 'data' },
|
||||
]),
|
||||
|
||||
new webpack.optimize.OccurrenceOrderPlugin(),
|
||||
new webpack.NoEmitOnErrorsPlugin(),
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new webpack.NamedModulesPlugin(),
|
||||
|
||||
new webpack.DefinePlugin({
|
||||
LOCAL: JSON.stringify(`http://localhost:${PORT}/`),
|
||||
}),
|
||||
|
||||
// ignore node lib from trezor-link
|
||||
new webpack.IgnorePlugin(/\/iconv-loader$/),
|
||||
],
|
||||
// ignoring "fs" import in fastxpub
|
||||
node: {
|
||||
fs: "empty",
|
||||
path: "empty",
|
||||
},
|
||||
}
|
@ -9,9 +9,17 @@ const constants: Object = Object.freeze({
|
||||
SRC: path.join(ABSOLUTE_BASE, 'src/'),
|
||||
PORT: 8081,
|
||||
INDEX: path.join(ABSOLUTE_BASE, 'src/index.html'),
|
||||
TREZOR_CONNECT_ROOT: path.join(ABSOLUTE_BASE, '../trezor.js2/'),
|
||||
TREZOR_CONNECT_ROOT: path.join(ABSOLUTE_BASE, '../trezor-connect/'),
|
||||
});
|
||||
|
||||
export const TREZOR_CONNECT_ROOT: string = constants.TREZOR_CONNECT_ROOT;
|
||||
export const TREZOR_CONNECT: string = path.join(constants.TREZOR_CONNECT_ROOT, 'src/js/index');
|
||||
export const TREZOR_IFRAME: string = path.join(constants.TREZOR_CONNECT_ROOT, 'src/js/iframe/iframe.js');
|
||||
export const TREZOR_POPUP: string = path.join(constants.TREZOR_CONNECT_ROOT, 'src/js/popup/popup.js');
|
||||
export const TREZOR_WEBUSB: string = path.join(constants.TREZOR_CONNECT_ROOT, 'src/js/webusb/index.js');
|
||||
export const TREZOR_CONNECT_HTML: string = path.join(constants.TREZOR_CONNECT_ROOT, 'src/html/');
|
||||
export const TREZOR_CONNECT_FILES: string = path.join(constants.TREZOR_CONNECT_ROOT, 'src/data/');
|
||||
|
||||
export const BUILD: string = constants.BUILD;
|
||||
export const SRC: string = constants.SRC;
|
||||
export const PORT: string = constants.PORT;
|
||||
|
13
yarn.lock
13
yarn.lock
@ -3361,7 +3361,7 @@ eventemitter3@^3.0.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.0.tgz#090b4d6cdbd645ed10bf750d4b5407942d7ba163"
|
||||
|
||||
events@^1.0.0:
|
||||
events@^1.0.0, events@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
|
||||
|
||||
@ -8787,9 +8787,14 @@ tr46@^1.0.1:
|
||||
dependencies:
|
||||
punycode "^2.1.0"
|
||||
|
||||
trezor-connect@5.0.13:
|
||||
version "5.0.13"
|
||||
resolved "https://registry.yarnpkg.com/trezor-connect/-/trezor-connect-5.0.13.tgz#2feee3d6644f8c3effd445b60ed80e7d5731469a"
|
||||
trezor-connect@^5.0.28:
|
||||
version "5.0.28"
|
||||
resolved "https://registry.yarnpkg.com/trezor-connect/-/trezor-connect-5.0.28.tgz#eb39bb0aa2a7555623251f0fb301233886fcdd09"
|
||||
dependencies:
|
||||
babel-polyfill "^6.26.0"
|
||||
babel-runtime "^6.26.0"
|
||||
events "^1.1.1"
|
||||
whatwg-fetch "^2.0.4"
|
||||
|
||||
trim-newlines@^1.0.0:
|
||||
version "1.0.0"
|
||||
|
Loading…
Reference in New Issue
Block a user