Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Latest commit

 

History

History
81 lines (56 loc) · 1.53 KB

api.md

File metadata and controls

81 lines (56 loc) · 1.53 KB

Node.js API

Same as webpack's Node.js API.

// udk(options, callback?): ICompiler | IWatcher?;

const udk = require('udk');

const multiConfig = [
  { name: 'client' },
  { name: 'server', dependencies: [ 'client' ] }
];

udk(multiConfig, (err, stats) => console.log(err || stats.toString()));

Compiler

run

// run(callback: (err: Error | null, stats: webpack.Stats) => void): void
const udk = require('udk');

const multiConfig = [
  { name: 'client' },
  { name: 'server', dependencies: [ 'client' ] }
];

const compiler = udk(multiConfig);

compiler.run((err, stats) => console.log(err || stats.toString()))

watch

// watch(
//   options: webpack.WatchOptions,
//   handler: (err: Error | null, stats: webpack.Stats) => void
// ): webpack.Watching

const udk = require('udk');

const multiConfig = [
  { name: 'client' },
  { name: 'server', dependencies: [ 'client' ] }
];

const compiler = udk(multiConfig);

const watching = compiler.watch(
  { aggregateTimeout: 200 },
  (err, stats) => console.log(err || stats.toString())
);

Watching

close

// close(callback?: () => void) : void

const udk = require('udk');

const multiConfig = [
  { name: 'client' },
  { name: 'server', dependencies: [ 'client' ] },
];

const compiler = udk(multiConfig);

const watching = compiler.watch(
  { aggregateTimeout: 200 },
  (err, stats) => console.log(err || stats.toString())
);

watching.close(() => console.log('Stop watching'));