This package has been deprecated

Author message:

No longer supported.

@phylum/webpack-task

3.0.0 • Public • Published

Webpack Task

Coverage Status Build Status Version License

A pipeline task that bundles code using webpack.

Installation

npm i @phylum/webpack-task webpack

Supported webpack versions range from 3.11.0 to 4.x.x

Usage

const createWebpackTask = require('@phylum/webpack-task')

// Create a new pipeline task:
const webpackTask = createWebpackTask(config[, webpack])
  • config <webpack.Compiler> | <object> | <function> - This can be a webpack compiler, a webpack config or a function that creates one of these.
    • ctx <Context> - The pipeline context of the webpack task is passed with the first argument.
    • return <webpack.Compiler> | <object> | <Promise> - Return a webpack compiler, config or a promise that resolves to one of these.
  • webpack <webpack> - Optional. Specify a specific webpack module to use instead of the default installed one.

Integration

The webpack task can be used like a pipeline task.
It will resolve to the webpack stats emitted by the compiler. In case of a critical compiler error, the task will reject with that error.

const webpackTask = createWebpackTask({
	// Webpack config...
})

async function myTask(ctx) {
	const stats = await ctx.use(webpackTask)
}

Passing custom options

To customize the webpack configuration based on pipeline data, pass a function with the config argument:

// For instance, set the mode:
const webpackTask = createWebpackTask(async ctx => {
	return {
		mode: ctx.pipeline.data.mode,
		watch: ctx.pipeline.data.watch
		// webpack config...
	}
})

const pipeline = new Pipeline(webpackTask)
pipeline.data.mode = 'development'
pipeline.data.watch = true

Watch mode

To enable watch mode use webpack's watch options. Each time, an updates is emitted, the task will push a new state.

Readme

Keywords

none

Package Sidebar

Install

npm i @phylum/webpack-task

Weekly Downloads

1

Version

3.0.0

License

MIT

Unpacked Size

8.78 kB

Total Files

8

Last publish

Collaborators

  • mpt