@ice/webpack-modify
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@ice/webpack-modify

This package providers several APIs to simplify the modification of webpack configurations.

Usage

import { removeLoader, modifyLoader, addLoader, removePlugin } from '@ice/webpack-modify';

let modifiedConfig = {};

const webpackConfig = {
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [{ loader: "style-loader" }, { loader: "sass-loader" }],
      },
    ],
  },
};

// remove loader
modifiedConfig = removeLoader(webpackConfig, {
  rule: 'css',
  loader: 'style-loader',
});
// modify loader
modifiedConfig = modifyLoader(webpackConfig, {
  rule: 'css',
  loader: 'style-loader',
  options: () => ({}),
});
// add loader
modifiedConfig = addLoader(webpackConfig, {
  rule: 'css',
  before: 'style-loader'
});
modifiedConfig = addLoader(webpackConfig, {
  rule: 'css',
  after: 'style-loader'
});
// modify webpack rule options
modifiedConfig = modifyRule(webpackConfig, {
  rule: 'css',
  options: () => {
    return [
      {
        loader: 'css-loader',
        options: () => ([]),
      },
    ]
  },
})
// remove plugin
modifiedConfig = removePlugin(webpackConfig, {
  pluginName: 'AssetsManifestPlugin',
});

Readme

Keywords

none

Package Sidebar

Install

npm i @ice/webpack-modify

Homepage

v3.ice.work

Weekly Downloads

8

Version

1.0.1

License

none

Unpacked Size

12 kB

Total Files

6

Last publish

Collaborators

  • linbudu
  • answershuto
  • chenjun1011
  • luhengchang228
  • sobear
  • clarkxia
  • rax-publisher