webpack-addons

1.1.5 · abandoned · verified Sun Apr 19

webpack-addons is a utility suite designed to assist in creating webpack-cli addons by providing helper functions for common webpack configuration patterns and interactive Inquirer.js prompts. Originally published in 2017, its latest version is 1.1.5. This package is specifically tailored for scaffolding webpack configurations programmatically, offering utilities like `parseValue` for special string formatting, and `createArrowFunction` for dynamic entry points. A key differentiator was its inclusion of a `createCommonsChunkPlugin` helper, which is now deprecated in Webpack 4+ in favor of `optimization.splitChunks`. Given its last update date and the deprecation of core Webpack features it wraps, the package is considered unmaintained and potentially incompatible with modern webpack versions.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the use of `parseValue` for configuring webpack output, `createArrowFunction` for entry points, and the structure of an Inquirer `List` prompt utility within a simulated webpack-cli addon generator.

const { parseValue, createArrowFunction, List } = require('webpack-addons');

// Simulate a webpack-cli addon's generator context
class WebpackAddonGenerator {
  constructor() {
    this.configuration = {
      myScaffold: {
        webpackOptions: {}
      }
    };
  }

  // Example of applying utilities to webpack configuration
  applyConfiguration() {
    this.configuration.myScaffold.webpackOptions.output = {
      sourcePrefix: parseValue('\t\t')
    };
    this.configuration.myScaffold.webpackOptions.entry = createArrowFunction('src/main.js');

    console.log('Generated Webpack Output Source Prefix:', this.configuration.myScaffold.webpackOptions.output.sourcePrefix);
    console.log('Generated Webpack Entry:', this.configuration.myScaffold.webpackOptions.entry());
  }

  // Example of using an Inquirer prompt (requires actual Inquirer setup in a CLI)
  async promptUser() {
    // In a real CLI, this would be await inquirer.prompt(...)
    const entryChoice = List(
      'entryType',
      'What kind of entry do you want?',
      ['String', 'Function', 'Object']
    );
    console.log('Simulated Inquirer List prompt for entryType:', entryChoice.name, entryChoice.choices);
  }
}

const generator = new WebpackAddonGenerator();
generator.applyConfiguration();
generator.promptUser();

view raw JSON →