@rebox/web
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

@rebox/web npm

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[], // ['defaults'] by default
  globalConstants?: {
    [key: string]: string
  },
  globalAliases?: {
    [key: string]: string
  },
  props?: TJsonValue,
  isQuiet?: boolean, // false by default
  shouldGenerateSourceMaps?: boolean, // false by default
  shouldGenerateBundleAnalyzerReport?: boolean // false by default
}

const buildWebAppRelease: (userOptions: TBuildWebAppReleaseOptions) => Promise<void>
type TRunWebAppOptions = {
  entryPointPath: string,
  htmlTemplatePath: string,
  browsersList?: string[], // ['last 1 Chrome version', 'last 1 Firefox version'] by default
  assetsPath?: string,
  props?: TJsonValue,
  isQuiet?: boolean, // false by default
  shouldOpenBrowser?: boolean // false by default
}

const runWebApp: (options: TRunWebAppOptions) => Promise<() => Promise<void>>

Usage

// App.tsx
import { FC } from 'react'

export type TApp = {
  color: string
}

export const App: FC<TApp> = ({ color }) => (
  <h1 style={{ color }}>Test</h1>
)
<!-- template.html -->
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title>Test</title>
    <style>
      body { margin: 0 }
    </style>
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>
// build.ts
import { buildWebAppRelease } from '@rebox/web'

await buildWebAppRelease({
  entryPointPath: './App.tsx',
  htmlTemplatePath: './template.html',
  outputPath: './build/',
  props: {
    color: '#ff0000'
  }
})
// run.ts
import { runWebApp } from '@rebox/web'

await runWebApp({
  entryPointPath: './App.tsx',
  htmlTemplatePath: './template.html',
  props: {
    color: '#ff0000'
  }
})

Readme

Keywords

Package Sidebar

Install

npm i @rebox/web

Weekly Downloads

70,313

Version

5.0.0

License

MIT

Unpacked Size

19.3 kB

Total Files

14

Last publish

Collaborators

  • psxcode
  • deepsweet
  • fosimus