API

WARNING

This page is still work-in-progress

Creating a Poi instance:

const poi = new Poi()

console.log(poi.mode)

constructor(argv?)

  • argv: string[] Default to process.argv

mode

  • Type: string
  • Default: test
  • Values: production development test

Get the mode that the bundler is running under.

cli

  • Type: CAC

The CLI instance, created from CAC.

config

  • Type: object

Poi config.

resolveCwd(...args: string[])

Like path.resolve.

localResolve(pkg)

  • Type: (pkg: string) => string | null

Resolve a package from current working directory.

localRequire(pkg)

  • Type: (pkg: string) => string | null

Require a package from current working directory.

getCacheConfig(dir, keys, files?)

  • Type: (dir: string, keys: {[k: string]: string}, files: string[])

Get the config for cache-loader. keys and the contents of files are used to generate cache identifier.

createWebpackChain(opts?)

  • Type: (opts: {[k:string]:any}) => WebpackChain

Create a webpack-chain instance.

opts will be available as the second argument of chainWebpack in the config file.

createWebpackCompiler(config)

  • Type: (config: WebpackConfig)

Create a webpack compiler from raw webpack config.

hook('createCLI', handler: Handler)

type Handler = (opts: Opts) => void

interface Opts {
  /** The default Poi command */
  command: Command
  /** CLI args */
  args: Args
}

interface Args {
  has: (arg: string) => boolean
  get: (arg: string) => any
}

hook('createWebpackChain', handler: Handler)

type Handler = (config: WebpackChain, opts: Opts) => void

interface Opts {
  type: string
  mode: 'production' | 'development' | 'test'
  [k: string]: any
}

run()

  • Type: () => Promise<void>

Parse CLI args and run commands.

Last Updated: 12/8/2018, 8:44:46 AM