@rebox/web
Set of helpers to deal with React applications using our Babel config.
Install
$ yarn add @rebox/web
API
type TBuildWebAppReleaseOptions = {
entryPointPath: string,
htmlTemplatePath: string,
outputPath: string,
browsersList?: string[],
globalConstants?: {
[key: string]: string
},
globalAliases?: {
[key: string]: string
},
props?: TJsonValue,
isQuiet?: boolean,
shouldGenerateSourceMaps?: boolean,
shouldGenerateBundleAnalyzerReport?: boolean
}
const buildWebAppRelease: (userOptions: TBuildWebAppReleaseOptions) => Promise<void>
type TRunWebAppOptions = {
entryPointPath: string,
htmlTemplatePath: string,
browsersList?: string[],
assetsPath?: string,
props?: TJsonValue,
isQuiet?: boolean,
shouldOpenBrowser?: boolean
}
const runWebApp: (options: TRunWebAppOptions) => Promise<() => Promise<void>>
Usage
import { FC } from 'react'
export type TApp = {
color: string
}
export const App: FC<TApp> = ({ color }) => (
<h1 style={{ color }}>Test</h1>
)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Test</title>
<style>
body { margin: 0 }
</style>
</head>
<body>
<div id="root"></div>
</body>
</html>
import { buildWebAppRelease } from '@rebox/web'
await buildWebAppRelease({
entryPointPath: './App.tsx',
htmlTemplatePath: './template.html',
outputPath: './build/',
props: {
color: '#ff0000'
}
})
import { runWebApp } from '@rebox/web'
await runWebApp({
entryPointPath: './App.tsx',
htmlTemplatePath: './template.html',
props: {
color: '#ff0000'
}
})