Skip to main content
Version: 6.x

How to Write Plugins

Ko support use plugin to modify internal configs and behaviors.Here is an example:

const VersionWebpackPlugin = require('./version-webpack-plugin');
module.exports = {
plugins: [
{
key: 'WebpackPlugin',
action: 'add',
opts: {
name: 'VersionWebpackPlugin',
fn: () => new VersionWebpackPlugin(),
},
},
],
}

As you can see, you can register your own ko plugin in via add plugins config in ko.config.js, and you should specify key, action and opts values:

  • key: supported hook keys, only WebpackPlugin & ModifyWebpack are supported currently.
  • action: supported actions, you can use add when add configs or use update when you want fully control current configs
  • opts: all opts passed will use internally via tapable, supported types:
export type HookItem = {
name: string;
fn: Function;
stage?: number;
before?: string;
};