webpkr = require('webpkr');
|
Creates a new instance of Webpkr
with the supplied options and calls buildFile()
on it and returns the resulting webpack
configuration.
opts.config |
|
webpkr initialization module |
|
opts.projectDir |
|
project directory |
|
opts.buildDir |
|
directory where output is written |
|
opts.environments |
|
|
|
Compiles the supplied DSL build script into a configuration tree.
closure |
|
the build script |
returns |
|
configuration tree |
const { Webpkr } = require( '../' );
const webpkr = new Webpkr();
const tree = webpkr.compile( () => {
context( projectDir )
entry( './src/index.js' )
output( () => {
filename( 'bundle.js' )
path$( 'dist' )
} )
} )
// print configuration tree
console.log( tree.toAsciiTree() );
└─webpackConfig, WebpackNodeExt, webpackConfig, [ undefined ]
├─context, ContextNodeExt, context, [ '/Users/venkat/proj/repos...'
├─entry, EntryNodeExt, entry, [ './src/index.js' ]
└─output, OutputNodeExt, output, [ undefined ]
├─filename, FilenameNodeExt, node.__filename, [ 'bundle.js' ]
└─path$, PathNodeExt, output.path, [ 'dist' ]
Loads the DSL build script from the supplied file and returns the compiled configuration tree. Relative paths are resolved from projectDir
.
file |
|
path to the build script |
returns |
|
configuration tree |
Loads the DSL build script from the supplied file, builds it and returns a Function
which can be passed to webpack
.
file |
|
path to the build script |
returns |
|
webpack configuration |
The returned Function accepts a single parameter. The webpack CLI uses this parameter to pass commandline arguments set via --env to the configuration script. These arguments are avilable via a global object cliArgs .
|
When using the webpack Node API, the function must be called and the resulting object should be passed to webpack() .
|
Emitted after the DSL is compiled into a configuration tree. The tree is passed as the only argument to the event.
Emitted during the evaluation phase, after each node is evaluated. The current node and its evaluated value are passed as arguments.
Emitted after the entire configuration tree is evaluated. The final webpack
configuration object is passed as the only argument.