Seed Webpack Plugin
Basic webpack plugins
BACKGROUND
There is a lot of duplication in the development of Webpack plugins, so all '@dumlj/*-webpack-plugin's can inherit this basic plugin to make development more convenient.
FEATURE
- Check for updates uniformly. Update prompts will only come from one checker, and only dependencies declared in
package.json
will be prompted (in nested plug-ins, undeclared dependencies will be ignored). - Provide some more general methods.
INSTALL
$ npm install --dev @dumlj/seed-webpack-plugin
$ yarn add --dev @dumlj/seed-webpack-plugin
$ pnpm add @dumlj/seed-webpack-plugin -D
USAGE
import { SeedWebpackPlugin, type SeedWebpackPluginOptions } from '@dumlj/seed-webpack-plugin'
import type { Compiler } from 'webpack'
export interface CustomWebpackPluginOptions extends SeedWebpackPluginOptions {
unnecessary: string
}
export class CustomWebpackPlugin extends SeedWebpackPlugin {
static PLUGIN_NAME = 'custom-webpack-plugin'
protected unnecessary: string
constructor(options?: CustomWebpackPluginOptions) {
super(options)
const { unnecessary } = options || {}
this.unnecessary = unnecessary
}
public apply(compiler: Compiler) {
super.apply(compiler)
if (this.isSkipIncomplete('skip operation when necessary options are missed.', { unnecessary: this.unnecessary })) {
return
}
compiler.hooks.thisCompilation.tap(this.pluginName, () => {
this.logger.info('todo something...')
})
}
}
LIVE DEMO
INTERNAL DEPENDENCIES
@dumlj/seed-webpack-plugin
├─┬ @dumlj/feature-updater
│ ├─── @dumlj/shell-lib
│ ├─── @dumlj/util-lib
│ └─── @dumlj/mock-libPRIVATE
└── @dumlj/mock-libPRIVATE