2.5.26 • Published 21 days ago

@dumlj/seed-webpack-plugin v2.5.26

Weekly downloads
-
License
MIT
Repository
github
Last release
21 days ago

License: MIT  Github Repo  NPM Version  See Docs  codecov  DeepSource 

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

# use npm
$ npm install --dev @dumlj/seed-webpack-plugin
# use yarn
$ yarn add --dev @dumlj/seed-webpack-plugin
# use pnpm
$ 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