feat: modularisation (#244)
* chore: gitignore for lib directory * build: packageing for webpack lib build * build: webpack config * feat: expose App component with beeApiUrl parameter * build: tsconfig for library build * build: main property of package json for tsc build * refactor: rename beeUrl option to beeApiUrl * refactor: manange config class instead of process.env calls * build: babelrc config * build: babel plugins and presets for webpack build * chore: serve.js chmod * build(refactor): webpack build * refactor: number notation * chore: webpack and package config change * build: add babel preset-env * chore: prepare script also builds component lib * feat: typegen * revert: set back prepare command * build: assets loader config * feat: beeDebugApiUrl * refactor: move test files to the test folder because of typegen * feat: locked api settings * chore: depcheck ignores * chore: types check script * ci: check types * ci: publish with library * chore: add webpack as devDep * chore: locked semver * chore: remove debug logging * style: webpack config * chore: react and react-dom as dependency * chore: package-lock * fix: clean package-lock init * refactor: fix versions in package.json
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = function (api) {
|
||||
const targets = '>1% and not ie 11 and not dead'
|
||||
api.cache(true)
|
||||
api.cacheDirectory = true
|
||||
|
||||
return {
|
||||
presets: [
|
||||
'@babel/preset-typescript',
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets,
|
||||
modules: false,
|
||||
}
|
||||
],
|
||||
['@babel/preset-react', {runtime: 'automatic' }]
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
"babel-plugin-tsconfig-paths",
|
||||
{
|
||||
"relative": true,
|
||||
"extensions": [
|
||||
".js",
|
||||
".jsx",
|
||||
".ts",
|
||||
".tsx",
|
||||
".es",
|
||||
".es6",
|
||||
".mjs"
|
||||
],
|
||||
"rootDir": ".",
|
||||
"tsconfig": "tsconfig.lib.json",
|
||||
}
|
||||
],
|
||||
"syntax-dynamic-import",
|
||||
'@babel/plugin-proposal-class-properties',
|
||||
[
|
||||
'@babel/plugin-transform-runtime',
|
||||
{
|
||||
helpers: false,
|
||||
regenerator: true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
+17
-1
@@ -1,3 +1,19 @@
|
||||
{
|
||||
"ignores": ["@types/jest", "@commitlint/config-conventional", "@types/react-router"]
|
||||
"ignores": [
|
||||
"@types/jest",
|
||||
"@commitlint/config-conventional",
|
||||
"@types/react-router",
|
||||
"@babel/core",
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-transform-runtime",
|
||||
"@babel/preset-env",
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
"babel-loader",
|
||||
"babel-plugin-syntax-dynamic-import",
|
||||
"babel-plugin-tsconfig-paths",
|
||||
"file-loader",
|
||||
"ts-node",
|
||||
"webpack-cli"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ jobs:
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Types check
|
||||
run: npm run check:types
|
||||
|
||||
- name: Dependency check
|
||||
run: npm run depcheck
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ jobs:
|
||||
node-version: 14
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- run: npm ci
|
||||
- run: npm run compile:types
|
||||
- run: npm build:component
|
||||
- run: npm publish --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
# production
|
||||
/build
|
||||
/lib
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
|
||||
Generated
+6852
-2002
File diff suppressed because it is too large
Load Diff
+27
-5
@@ -15,6 +15,8 @@
|
||||
"bin": {
|
||||
"bee-dashboard": "./serve.js"
|
||||
},
|
||||
"main": "lib/App.js",
|
||||
"types": "lib/src/App.d.ts",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ethersphere/bee-dashboard/issues/"
|
||||
},
|
||||
@@ -39,9 +41,9 @@
|
||||
"notistack": "1.0.10",
|
||||
"opener": "1.5.2",
|
||||
"qrcode.react": "1.0.1",
|
||||
"react": "17.0.2",
|
||||
"react": ">= 17.0.2",
|
||||
"react-copy-to-clipboard": "5.0.4",
|
||||
"react-dom": "17.0.2",
|
||||
"react-dom": ">= 17.0.2",
|
||||
"react-feather": "2.0.9",
|
||||
"react-identicons": "1.2.5",
|
||||
"react-router": "5.2.0",
|
||||
@@ -51,10 +53,16 @@
|
||||
"serve-handler": "6.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.16.0",
|
||||
"@babel/plugin-proposal-class-properties": "7.16.0",
|
||||
"@babel/plugin-transform-runtime": "7.16.4",
|
||||
"@babel/preset-env": "7.16.4",
|
||||
"@babel/preset-react": "7.16.0",
|
||||
"@babel/preset-typescript": "7.16.0",
|
||||
"@commitlint/config-conventional": "14.1.0",
|
||||
"@testing-library/jest-dom": "5.15.0",
|
||||
"@testing-library/react": "12.1.2",
|
||||
"@types/file-saver": "^2.0.4",
|
||||
"@types/file-saver": "2.0.4",
|
||||
"@types/jest": "27.0.2",
|
||||
"@types/qrcode.react": "1.0.2",
|
||||
"@types/react": "17.0.34",
|
||||
@@ -67,6 +75,9 @@
|
||||
"@typescript-eslint/eslint-plugin": "4.33.0",
|
||||
"@typescript-eslint/parser": "4.33.0",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-loader": "8.1.0",
|
||||
"babel-plugin-syntax-dynamic-import": "6.18.0",
|
||||
"babel-plugin-tsconfig-paths": "1.0.2",
|
||||
"depcheck": "1.4.2",
|
||||
"eslint": "7.24.0",
|
||||
"eslint-config-prettier": "8.2.0",
|
||||
@@ -79,20 +90,31 @@
|
||||
"eslint-plugin-react": "7.23.2",
|
||||
"eslint-plugin-react-hooks": "4.2.0",
|
||||
"eslint-plugin-testing-library": "3.10.2",
|
||||
"file-loader": "6.2.0",
|
||||
"prettier": "2.4.1",
|
||||
"react-scripts": "4.0.3",
|
||||
"ts-node": "^10.4.0",
|
||||
"typescript": "4.4.4",
|
||||
"web-vitals": "2.1.2"
|
||||
"web-vitals": "2.1.2",
|
||||
"webpack": "4.44.2",
|
||||
"webpack-cli": "^4.9.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">= 17.0.2",
|
||||
"react-dom": ">= 17.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "npm run build",
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"build:component": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' webpack --mode=production",
|
||||
"compile:types": "tsc --project tsconfig.lib.json --emitDeclarationOnly --declaration",
|
||||
"test": "react-scripts test",
|
||||
"serve": "node ./serve.js",
|
||||
"depcheck": "depcheck .",
|
||||
"lint": "eslint --fix \"src/**/*.ts\" \"src/**/*.tsx\" && prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
|
||||
"lint:check": "eslint \"src/**/*.ts\" \"src/**/*.tsx\" && prettier --check \"src/**/*.ts\" \"src/**/*.tsx\""
|
||||
"lint:check": "eslint \"src/**/*.ts\" \"src/**/*.tsx\" && prettier --check \"src/**/*.ts\" \"src/**/*.tsx\"",
|
||||
"check:types": "tsc --project tsconfig.lib.json"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
|
||||
+9
-3
@@ -1,7 +1,7 @@
|
||||
import CssBaseline from '@material-ui/core/CssBaseline'
|
||||
import { ThemeProvider } from '@material-ui/core/styles'
|
||||
import { SnackbarProvider } from 'notistack'
|
||||
import { ReactElement } from 'react'
|
||||
import React, { ReactElement } from 'react'
|
||||
import { BrowserRouter as Router } from 'react-router-dom'
|
||||
import './App.css'
|
||||
import Dashboard from './layout/Dashboard'
|
||||
@@ -13,10 +13,16 @@ import { Provider as StampsProvider } from './providers/Stamps'
|
||||
import BaseRouter from './routes'
|
||||
import { theme } from './theme'
|
||||
|
||||
const App = (): ReactElement => (
|
||||
interface Props {
|
||||
beeApiUrl?: string
|
||||
beeDebugApiUrl?: string
|
||||
lockedApiSettings?: boolean
|
||||
}
|
||||
|
||||
const App = ({ beeApiUrl, beeDebugApiUrl, lockedApiSettings }: Props): ReactElement => (
|
||||
<div className="App">
|
||||
<ThemeProvider theme={theme}>
|
||||
<SettingsProvider>
|
||||
<SettingsProvider beeApiUrl={beeApiUrl} beeDebugApiUrl={beeDebugApiUrl} lockedApiSettings={lockedApiSettings}>
|
||||
<BeeProvider>
|
||||
<StampsProvider>
|
||||
<FileProvider>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
|
||||
import { Alert, AlertTitle } from '@material-ui/lab'
|
||||
import { ReactElement } from 'react'
|
||||
|
||||
const LIMIT = 100_000_000 // 100 megabytes
|
||||
const LIMIT = 100000000 // 100 megabytes
|
||||
|
||||
interface Props {
|
||||
files: File[]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Typography } from '@material-ui/core/'
|
||||
import QRCodeModal from './QRCodeModal'
|
||||
import ClipboardCopy from './ClipboardCopy'
|
||||
|
||||
import Identicon from 'react-identicons'
|
||||
import { ReactElement } from 'react'
|
||||
import Identicon from 'react-identicons'
|
||||
import { config } from '../config'
|
||||
import ClipboardCopy from './ClipboardCopy'
|
||||
import QRCodeModal from './QRCodeModal'
|
||||
|
||||
interface Props {
|
||||
address: string | undefined
|
||||
@@ -36,9 +36,7 @@ export default function EthereumAddress(props: Props): ReactElement {
|
||||
}
|
||||
: { marginRight: '7px' }
|
||||
}
|
||||
href={`${process.env.REACT_APP_BLOCKCHAIN_EXPLORER_URL}/${props.transaction ? 'tx' : 'address'}/${
|
||||
props.address
|
||||
}`}
|
||||
href={`${config.BLOCKCHAIN_EXPLORER_URL}/${props.transaction ? 'tx' : 'address'}/${props.address}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
||||
@@ -55,6 +55,7 @@ interface Props {
|
||||
onChange?: (value: string) => void
|
||||
onConfirm: (value: string) => void
|
||||
mapperFn?: (value: string) => string
|
||||
locked?: boolean
|
||||
}
|
||||
|
||||
export default function ExpandableListItemKey({
|
||||
@@ -68,6 +69,7 @@ export default function ExpandableListItemKey({
|
||||
helperText,
|
||||
placeholder,
|
||||
mapperFn,
|
||||
locked,
|
||||
}: Props): ReactElement | null {
|
||||
const classes = useStyles()
|
||||
const [open, setOpen] = useState(Boolean(expandedOnly))
|
||||
@@ -96,7 +98,7 @@ export default function ExpandableListItemKey({
|
||||
<Typography variant="body2">
|
||||
<div>
|
||||
{!open && value}
|
||||
{!expandedOnly && (
|
||||
{!expandedOnly && !locked && (
|
||||
<IconButton size="small" className={classes.copyValue}>
|
||||
{open ? (
|
||||
<Minus onClick={toggleOpen} strokeWidth={1} />
|
||||
@@ -116,6 +118,7 @@ export default function ExpandableListItemKey({
|
||||
fullWidth
|
||||
className={classes.content}
|
||||
autoFocus
|
||||
hidden={locked}
|
||||
/>
|
||||
</Collapse>
|
||||
</Grid>
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { ReactElement } from 'react'
|
||||
import { BookOpen, DollarSign, FileText, Home, Layers, Settings } from 'react-feather'
|
||||
import { Link } from 'react-router-dom'
|
||||
import Logo from '../assets/logo.svg'
|
||||
import { config } from '../config'
|
||||
import { ROUTES } from '../routes'
|
||||
import SideBarItem from './SideBarItem'
|
||||
import SideBarStatus from './SideBarStatus'
|
||||
@@ -111,7 +112,7 @@ export default function SideBar(): ReactElement {
|
||||
</List>
|
||||
<Divider className={classes.divider} />
|
||||
<List>
|
||||
<MUILink href={process.env.REACT_APP_BEE_DOCS_HOST} target="_blank" className={classes.link}>
|
||||
<MUILink href={config.BEE_DOCS_HOST} target="_blank" className={classes.link}>
|
||||
<SideBarItem
|
||||
iconStart={<BookOpen className={classes.icon} />}
|
||||
iconEnd={<OpenInNewSharp className={classes.iconSmall} />}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { ReactElement } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import { Button, Grid, Link as MuiLink, Typography } from '@material-ui/core/'
|
||||
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
|
||||
import { Button, Grid, Typography, Link as MuiLink } from '@material-ui/core/'
|
||||
import { ROUTES } from '../routes'
|
||||
import type { ReactElement } from 'react'
|
||||
import { Activity } from 'react-feather'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { config } from '../config'
|
||||
import { ROUTES } from '../routes'
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
@@ -37,11 +37,11 @@ export default function TroubleshootConnectionCard(): ReactElement {
|
||||
<Grid item className={classes.content}>
|
||||
<Typography align="center">
|
||||
Please check your node status to fix the problem. You can also check out the{' '}
|
||||
<MuiLink href={process.env.REACT_APP_BEE_DOCS_HOST} target="_blank" rel="noreferrer">
|
||||
<MuiLink href={config.BEE_DOCS_HOST} target="_blank" rel="noreferrer">
|
||||
Swarm Bee Docs
|
||||
</MuiLink>{' '}
|
||||
or ask for support on the{' '}
|
||||
<MuiLink href={process.env.REACT_APP_BEE_DISCORD_HOST} target="_blank" rel="noreferrer">
|
||||
<MuiLink href={config.BEE_DISCORD_HOST} target="_blank" rel="noreferrer">
|
||||
Ethereum Swarm Discord
|
||||
</MuiLink>
|
||||
.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
function getProcessEnv(key: string): string | undefined | false {
|
||||
return typeof process === 'object' && process.env[key]
|
||||
}
|
||||
|
||||
class Config {
|
||||
public readonly BEE_API_HOST: string
|
||||
public readonly BEE_DEBUG_API_HOST: string
|
||||
public readonly BLOCKCHAIN_EXPLORER_URL: string
|
||||
public readonly BEE_DOCS_HOST: string
|
||||
public readonly BEE_DISCORD_HOST: string
|
||||
public readonly GITHUB_REPO_URL: string
|
||||
|
||||
constructor() {
|
||||
this.BEE_API_HOST =
|
||||
sessionStorage.getItem('api_host') || getProcessEnv('REACT_APP_BEE_HOST') || 'http://localhost:1633'
|
||||
this.BEE_DEBUG_API_HOST =
|
||||
sessionStorage.getItem('debug_api_host') || getProcessEnv('REACT_APP_BEE_DEBUG_HOST') || 'http://localhost:1635'
|
||||
this.BLOCKCHAIN_EXPLORER_URL =
|
||||
getProcessEnv('REACT_APP_BLOCKCHAIN_EXPLORER_URL') || 'https://blockscout.com/xdai/mainnet'
|
||||
this.BEE_DOCS_HOST = getProcessEnv('REACT_APP_BEE_DOCS_HOST') || 'https://docs.ethswarm.org/docs/'
|
||||
this.BEE_DISCORD_HOST = getProcessEnv('REACT_APP_BEE_DISCORD_HOST') || 'https://discord.gg/eKr9XPv7'
|
||||
this.GITHUB_REPO_URL =
|
||||
getProcessEnv('REACT_APP_BEE_GITHUB_REPO_URL') || 'https://api.github.com/repos/ethersphere/bee'
|
||||
}
|
||||
}
|
||||
|
||||
export const config = new Config()
|
||||
|
||||
export default config
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import axios from 'axios'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { config } from '../config'
|
||||
|
||||
export interface LatestBeeReleaseHook {
|
||||
latestBeeRelease: LatestBeeRelease | null
|
||||
@@ -14,7 +15,7 @@ export const useLatestBeeRelease = (): LatestBeeReleaseHook => {
|
||||
|
||||
useEffect(() => {
|
||||
axios
|
||||
.get(`${process.env.REACT_APP_BEE_GITHUB_REPO_URL}/releases/latest`)
|
||||
.get(`${config.GITHUB_REPO_URL}/releases/latest`)
|
||||
.then(res => {
|
||||
setLatestBeeRelease(res.data)
|
||||
})
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import { ReactElement, useContext } from 'react'
|
||||
import { Context as SettingsContext } from '../../providers/Settings'
|
||||
import ExpandableList from '../../components/ExpandableList'
|
||||
import ExpandableListItemInput from '../../components/ExpandableListItemInput'
|
||||
import { Context as SettingsContext } from '../../providers/Settings'
|
||||
|
||||
export default function Settings(): ReactElement {
|
||||
const { apiUrl, apiDebugUrl, setApiUrl, setDebugApiUrl } = useContext(SettingsContext)
|
||||
const { apiUrl, apiDebugUrl, setApiUrl, setDebugApiUrl, lockedApiSettings } = useContext(SettingsContext)
|
||||
|
||||
return (
|
||||
<ExpandableList label="API Settings" defaultOpen>
|
||||
<ExpandableListItemInput label="Bee API" value={apiUrl} onConfirm={setApiUrl} />
|
||||
<ExpandableListItemInput label="Bee Debug API" value={apiDebugUrl} onConfirm={setDebugApiUrl} />
|
||||
<ExpandableListItemInput label="Bee API" value={apiUrl} onConfirm={setApiUrl} locked={lockedApiSettings} />
|
||||
<ExpandableListItemInput
|
||||
label="Bee Debug API"
|
||||
value={apiDebugUrl}
|
||||
onConfirm={setDebugApiUrl}
|
||||
locked={lockedApiSettings}
|
||||
/>
|
||||
</ExpandableList>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createContext, ReactChild, ReactElement, useState, useEffect } from 'react'
|
||||
import { Bee, BeeDebug } from '@ethersphere/bee-js'
|
||||
import { createContext, ReactChild, ReactElement, useEffect, useState } from 'react'
|
||||
import { config } from '../config'
|
||||
|
||||
interface ContextInterface {
|
||||
apiUrl: string
|
||||
@@ -8,16 +9,17 @@ interface ContextInterface {
|
||||
beeDebugApi: BeeDebug | null
|
||||
setApiUrl: (url: string) => void
|
||||
setDebugApiUrl: (url: string) => void
|
||||
lockedApiSettings: boolean
|
||||
}
|
||||
|
||||
const initialValues: ContextInterface = {
|
||||
apiUrl: sessionStorage.getItem('api_host') || process.env.REACT_APP_BEE_HOST || 'http://localhost:1633',
|
||||
apiDebugUrl:
|
||||
sessionStorage.getItem('debug_api_host') || process.env.REACT_APP_BEE_DEBUG_HOST || 'http://localhost:1635',
|
||||
apiUrl: config.BEE_API_HOST,
|
||||
apiDebugUrl: config.BEE_DEBUG_API_HOST,
|
||||
beeApi: null,
|
||||
beeDebugApi: null,
|
||||
setApiUrl: () => {}, // eslint-disable-line
|
||||
setDebugApiUrl: () => {}, // eslint-disable-line
|
||||
lockedApiSettings: false,
|
||||
}
|
||||
|
||||
export const Context = createContext<ContextInterface>(initialValues)
|
||||
@@ -25,13 +27,22 @@ export const Consumer = Context.Consumer
|
||||
|
||||
interface Props {
|
||||
children: ReactChild
|
||||
beeApiUrl?: string
|
||||
beeDebugApiUrl?: string
|
||||
lockedApiSettings?: boolean
|
||||
}
|
||||
|
||||
export function Provider({ children }: Props): ReactElement {
|
||||
export function Provider({
|
||||
children,
|
||||
beeApiUrl,
|
||||
beeDebugApiUrl,
|
||||
lockedApiSettings: extLockedApiSettings,
|
||||
}: Props): ReactElement {
|
||||
const [apiUrl, setApiUrl] = useState<string>(initialValues.apiUrl)
|
||||
const [apiDebugUrl, setDebugApiUrl] = useState<string>(initialValues.apiDebugUrl)
|
||||
const [beeApi, setBeeApi] = useState<Bee | null>(null)
|
||||
const [beeDebugApi, setBeeDebugApi] = useState<BeeDebug | null>(null)
|
||||
const [lockedApiSettings] = useState<boolean>(Boolean(extLockedApiSettings))
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
@@ -42,6 +53,14 @@ export function Provider({ children }: Props): ReactElement {
|
||||
}
|
||||
}, [apiUrl])
|
||||
|
||||
useEffect(() => {
|
||||
if (beeApiUrl) setApiUrl(beeApiUrl)
|
||||
}, [beeApiUrl])
|
||||
|
||||
useEffect(() => {
|
||||
if (beeDebugApiUrl) setDebugApiUrl(beeDebugApiUrl)
|
||||
}, [beeDebugApiUrl])
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
setBeeDebugApi(new BeeDebug(apiDebugUrl))
|
||||
@@ -52,7 +71,9 @@ export function Provider({ children }: Props): ReactElement {
|
||||
}, [apiDebugUrl])
|
||||
|
||||
return (
|
||||
<Context.Provider value={{ apiUrl, apiDebugUrl, beeApi, beeDebugApi, setApiUrl, setDebugApiUrl }}>
|
||||
<Context.Provider
|
||||
value={{ apiUrl, apiDebugUrl, beeApi, beeDebugApi, setApiUrl, setDebugApiUrl, lockedApiSettings }}
|
||||
>
|
||||
{children}
|
||||
</Context.Provider>
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const OPTIMAL_CONNECTED_PEERS = 200
|
||||
const OPTIMAL_POPULATION = 100_000
|
||||
const OPTIMAL_POPULATION = 100000
|
||||
const OPTIMAL_DEPTH = 12
|
||||
|
||||
interface Threshold {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
"outDir": "lib",
|
||||
"rootDirs": ["src"],
|
||||
"typeRoots": ["./src/@types", "node_modules/@types"]
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import Path from 'path'
|
||||
import { Configuration } from 'webpack'
|
||||
|
||||
// eslint-disable-next-line import/no-anonymous-default-export
|
||||
export default (): Configuration => {
|
||||
const entry = Path.resolve(__dirname, 'src', 'App.tsx')
|
||||
|
||||
return {
|
||||
mode: 'production',
|
||||
entry,
|
||||
output: {
|
||||
path: Path.resolve(__dirname, 'lib'),
|
||||
filename: 'App.js',
|
||||
library: 'beeDashboard',
|
||||
libraryTarget: 'umd',
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.css', '.png', '.svg', '.ttf', '.ts', '.tsx', '.js'],
|
||||
},
|
||||
devtool: 'source-map',
|
||||
externals: {
|
||||
// Use external version of React
|
||||
// react: 'root React',
|
||||
react: 'react',
|
||||
'react-dom': 'react-dom',
|
||||
},
|
||||
target: 'web',
|
||||
optimization: {
|
||||
minimize: false,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/i,
|
||||
use: ['style-loader', 'css-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.(png|jp(e*)g|svg|gif)$/,
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: 'assets/[name].[ext]',
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(ttf)$/,
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: 'assets/fonts/[name].[ext]',
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(ts|js|tsx|jsx)$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user