{"id":13452116,"url":"https://github.com/neutrinojs/webpack-chain","last_synced_at":"2025-10-05T17:31:17.126Z","repository":{"id":39450467,"uuid":"81127405","full_name":"neutrinojs/webpack-chain","owner":"neutrinojs","description":"A chaining API to generate and simplify the modification of Webpack configurations.","archived":true,"fork":false,"pushed_at":"2024-02-04T08:45:44.000Z","size":1152,"stargazers_count":3192,"open_issues_count":1,"forks_count":232,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-09-29T03:37:53.803Z","etag":null,"topics":["chain-methods","fluent","webpack","webpack-configuration","webpack2"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neutrinojs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-06T20:06:35.000Z","updated_at":"2025-09-23T19:32:49.000Z","dependencies_parsed_at":"2024-01-06T01:00:20.148Z","dependency_job_id":"a9db220c-f93f-48be-bc31-14c85a50407e","html_url":"https://github.com/neutrinojs/webpack-chain","commit_stats":{"total_commits":224,"total_committers":38,"mean_commits":5.894736842105263,"dds":0.6696428571428572,"last_synced_commit":"da73fab944e5ba6e1e902a7e134709907c8bea50"},"previous_names":["mozilla-neutrino/webpack-chain","mozilla-rpweb/webpack-chain"],"tags_count":52,"template":false,"template_full_name":null,"purl":"pkg:github/neutrinojs/webpack-chain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutrinojs%2Fwebpack-chain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutrinojs%2Fwebpack-chain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutrinojs%2Fwebpack-chain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutrinojs%2Fwebpack-chain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neutrinojs","download_url":"https://codeload.github.com/neutrinojs/webpack-chain/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutrinojs%2Fwebpack-chain/sbom","scorecard":{"id":661991,"data":{"date":"2025-08-11","repo":{"name":"github.com/neutrinojs/webpack-chain","commit":"da73fab944e5ba6e1e902a7e134709907c8bea50"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":6,"reason":"Found 10/16 approved changesets -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/neutrinojs/webpack-chain/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/neutrinojs/webpack-chain/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/neutrinojs/webpack-chain/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/neutrinojs/webpack-chain/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/neutrinojs/webpack-chain/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/neutrinojs/webpack-chain/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/neutrinojs/webpack-chain/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/neutrinojs/webpack-chain/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/neutrinojs/webpack-chain/ci.yml/main?enable=pin","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Mozilla Public License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"29 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T16:29:13.823Z","repository_id":39450467,"created_at":"2025-08-21T16:29:13.823Z","updated_at":"2025-08-21T16:29:13.823Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278487149,"owners_count":25995123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chain-methods","fluent","webpack","webpack-configuration","webpack2"],"created_at":"2024-07-31T07:01:13.504Z","updated_at":"2025-10-05T17:31:16.829Z","avatar_url":"https://github.com/neutrinojs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","打包工具","webpack","书签","Webpack"],"sub_categories":["webpack 辅助工具、Loader 和插件","Webpack","调试"],"readme":"# webpack-chain\n\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][npm-downloads]][npm-url]\n[![CI Status][ci-image]][ci-url]\n\nUse a chaining API to generate and simplify the modification of webpack 4 configurations.\n\nThis documentation corresponds to v7 of webpack-chain. For previous versions, see:\n\n* [v6 docs](https://github.com/neutrinojs/webpack-chain/tree/v6)\n* [v5 docs](https://github.com/neutrinojs/webpack-chain/tree/v5)\n* [v4 docs](https://github.com/neutrinojs/webpack-chain/tree/v4)\n* [v3 docs](https://github.com/neutrinojs/webpack-chain/tree/v3)\n* [v2 docs](https://github.com/neutrinojs/webpack-chain/tree/v2)\n* [v1 docs](https://github.com/neutrinojs/webpack-chain/tree/v1)\n\n_Note: while webpack-chain is utilized extensively in Neutrino, this package is\ncompletely standalone and can be used by any project._\n\n**[Chinese docs(中文文档)](https://github.com/Yatoo2018/webpack-chain/tree/zh-cmn-Hans)**\n\n## Introduction\n\nwebpack's core configuration is based on creating and modifying a\npotentially unwieldy JavaScript object. While this is OK for configurations\non individual projects, trying to share these objects across projects and\nmake subsequent modifications gets messy, as you need to have a deep\nunderstanding of the underlying object structure to make those changes.\n\n`webpack-chain` attempts to improve this process by providing a chainable or\nfluent API for creating and modifying webpack configurations. Key portions\nof the API can be referenced by user-specified names, which helps to\nstandardize how to modify a configuration across projects.\n\nThis is easier explained through the examples following.\n\n## Installation\n\n`webpack-chain` requires Node.js 12 or higher. `webpack-chain` also only creates\nconfiguration objects designed for use with webpack 4.\n\nYou may install this package using either Yarn or npm (choose one):\n\n**Yarn**\n\n```bash\nyarn add --dev webpack-chain\n```\n\n**npm**\n\n```bash\nnpm install --save-dev webpack-chain\n```\n\n## Getting Started\n\nOnce you have `webpack-chain` installed, you can start creating a\nwebpack configuration. For this guide, our example base configuration will\nbe `webpack.config.js` in the root of our project directory.\n\n```js\n// Require the webpack-chain module. This module exports a single\n// constructor function for creating a configuration API.\nconst Config = require('webpack-chain');\n\n// Instantiate the configuration with a new API\nconst config = new Config();\n\n// Make configuration changes using the chain API.\n// Every API call tracks a change to the stored configuration.\n\nconfig\n  // Interact with entry points\n  .entry('index')\n    .add('src/index.js')\n    .end()\n  // Modify output settings\n  .output\n    .path('dist')\n    .filename('[name].bundle.js');\n\n// Create named rules which can be modified later\nconfig.module\n  .rule('lint')\n    .test(/\\.js$/)\n    .pre()\n    .include\n      .add('src')\n      .end()\n    // Even create named uses (loaders)\n    .use('eslint')\n      .loader('eslint-loader')\n      .options({\n        rules: {\n          semi: 'off'\n        }\n      });\n\nconfig.module\n  .rule('compile')\n    .test(/\\.js$/)\n    .include\n      .add('src')\n      .add('test')\n      .end()\n    .use('babel')\n      .loader('babel-loader')\n      .options({\n        presets: [\n          ['@babel/preset-env', { modules: false }]\n        ]\n      });\n\n// Create named plugins too!\nconfig\n  .plugin('clean')\n    .use(CleanPlugin, [['dist'], { root: '/dir' }]);\n\n// Export the completed configuration object to be consumed by webpack\nmodule.exports = config.toConfig();\n```\n\nHaving shared configurations is also simple. Just export the configuration\nand call `.toConfig()` prior to passing to webpack.\n\n```js\n// webpack.core.js\nconst Config = require('webpack-chain');\nconst config = new Config();\n\n// Make configuration shared across targets\n// ...\n\nmodule.exports = config;\n\n// webpack.dev.js\nconst config = require('./webpack.core');\n\n// Dev-specific configuration\n// ...\nmodule.exports = config.toConfig();\n\n// webpack.prod.js\nconst config = require('./webpack.core');\n\n// Production-specific configuration\n// ...\nmodule.exports = config.toConfig();\n```\n\n## ChainedMap\n\nOne of the core API interfaces in webpack-chain is a `ChainedMap`. A\n`ChainedMap` operates similar to a JavaScript Map, with some conveniences for\nchaining and generating configuration. If a property is marked as being a\n`ChainedMap`, it will have an API and methods as described below:\n\n**Unless stated otherwise, these methods will return the `ChainedMap`, allowing\nyou to chain these methods.**\n\n```js\n// Remove all entries from a Map.\nclear()\n```\n\n```js\n// Remove a single entry from a Map given its key.\n// key: *\ndelete(key)\n```\n\n```js\n// Fetch the value from a Map located at the corresponding key.\n// key: *\n// returns: value\nget(key)\n```\n\n```js\n// Fetch the value from a Map located at the corresponding key.\n// If the key is missing, the key is set to the result of function fn.\n// key: *\n// fn: Function () -\u003e value\n// returns: value\ngetOrCompute(key, fn)\n```\n\n```js\n// Set a value on the Map stored at the `key` location.\n// key: *\n// value: *\nset(key, value)\n```\n\n```js\n// Returns `true` or `false` based on whether a Map as has a value set at a\n// particular key.\n// key: *\n// returns: Boolean\nhas(key)\n```\n\n```js\n// Returns an array of all the values stored in the Map.\n// returns: Array\nvalues()\n```\n\n```js\n// Returns an object of all the entries in the backing Map\n// where the key is the object property, and the value\n// corresponding to the key. Will return `undefined` if the backing\n// Map is empty.\n// This will order properties by their name if the value is\n// a ChainedMap that used .before() or .after().\n// returns: Object, undefined if empty\nentries()\n```\n\n```js\n// Provide an object which maps its properties and values\n// into the backing Map as keys and values.\n// You can also provide an array as the second argument\n// for property names to omit from being merged.\n// obj: Object\n// omit: Optional Array\nmerge(obj, omit)\n```\n\n```js\n// Execute a function against the current configuration context\n// handler: Function -\u003e ChainedMap\n  // A function which is given a single argument of the ChainedMap instance\nbatch(handler)\n```\n\n```js\n// Conditionally execute a function to continue configuration\n// condition: Boolean\n// whenTruthy: Function -\u003e ChainedMap\n  // invoked when condition is truthy, given a single argument of the ChainedMap instance\n// whenFalsy: Optional Function -\u003e ChainedMap\n  // invoked when condition is falsy, given a single argument of the ChainedMap instance\nwhen(condition, whenTruthy, whenFalsy)\n```\n\n## ChainedSet\n\nAnother of the core API interfaces in webpack-chain is a `ChainedSet`. A\n`ChainedSet` operates similar to a JavaScript Set, with some conveniences for\nchaining and generating configuration. If a property is marked as being a\n`ChainedSet`, it will have an API and methods as described below:\n\n**Unless stated otherwise, these methods will return the `ChainedSet`, allowing\nyou to chain these methods.**\n\n```js\n// Add/append a value to the end of a Set.\n// value: *\nadd(value)\n```\n\n```js\n// Add a value to the beginning of a Set.\n// value: *\nprepend(value)\n```\n\n```js\n// Remove all values from a Set.\nclear()\n```\n\n```js\n// Remove a specific value from a Set.\n// value: *\ndelete(value)\n```\n\n```js\n// Returns `true` or `false` based on whether or not the\n// backing Set contains the specified value.\n// value: *\n// returns: Boolean\nhas(value)\n```\n\n```js\n// Returns an array of values contained in the backing Set.\n// returns: Array\nvalues()\n```\n\n```js\n// Concatenates the given array to the end of the backing Set.\n// arr: Array\nmerge(arr)\n```\n\n```js\n// Execute a function against the current configuration context\n// handler: Function -\u003e ChainedSet\n  // A function which is given a single argument of the ChainedSet instance\nbatch(handler)\n```\n\n```js\n// Conditionally execute a function to continue configuration\n// condition: Boolean\n// whenTruthy: Function -\u003e ChainedSet\n  // invoked when condition is truthy, given a single argument of the ChainedSet instance\n// whenFalsy: Optional Function -\u003e ChainedSet\n  // invoked when condition is falsy, given a single argument of the ChainedSet instance\nwhen(condition, whenTruthy, whenFalsy)\n```\n\n## Shorthand methods\n\nA number of shorthand methods exist for setting a value on a `ChainedMap`\nwith the same key as the shorthand method name.\nFor example, `devServer.hot` is a shorthand method, so it can be used as:\n\n```js\n// A shorthand method for setting a value on a ChainedMap\ndevServer.hot(true);\n\n// This would be equivalent to:\ndevServer.set('hot', true);\n```\n\nA shorthand method is chainable, so calling it will return the original\ninstance, allowing you to continue to chain.\n\n### Config\n\nCreate a new configuration object.\n\n```js\nconst Config = require('webpack-chain');\n\nconst config = new Config();\n```\n\nMoving to deeper points in the API will change the context of what you\nare modifying. You can move back to the higher context by either referencing\nthe top-level `config` again, or by calling `.end()` to move up one level.\nIf you are familiar with jQuery, `.end()` works similarly. All API calls\nwill return the API instance at the current context unless otherwise\nspecified. This is so you may chain API calls continuously if desired.\n\nFor details on the specific values that are valid for all shorthand and\nlow-level methods, please refer to their corresponding name in the\n[webpack docs hierarchy](https://webpack.js.org/configuration/).\n\n```js\nConfig : ChainedMap\n```\n\n#### Config shorthand methods\n\n```js\nconfig\n  .amd(amd)\n  .bail(bail)\n  .cache(cache)\n  .devtool(devtool)\n  .context(context)\n  .externals(externals)\n  .loader(loader)\n  .name(name)\n  .mode(mode)\n  .parallelism(parallelism)\n  .profile(profile)\n  .recordsPath(recordsPath)\n  .recordsInputPath(recordsInputPath)\n  .recordsOutputPath(recordsOutputPath)\n  .stats(stats)\n  .target(target)\n  .watch(watch)\n  .watchOptions(watchOptions)\n```\n\n#### Config entryPoints\n\n```js\n// Backed at config.entryPoints : ChainedMap\nconfig.entry(name) : ChainedSet\n\nconfig\n  .entry(name)\n    .add(value)\n    .add(value)\n\nconfig\n  .entry(name)\n    .clear()\n\n// Using low-level config.entryPoints:\n\nconfig.entryPoints\n  .get(name)\n    .add(value)\n    .add(value)\n\nconfig.entryPoints\n  .get(name)\n    .clear()\n```\n\n#### Config output: shorthand methods\n\n```js\nconfig.output : ChainedMap\n\nconfig.output\n  .auxiliaryComment(auxiliaryComment)\n  .chunkFilename(chunkFilename)\n  .chunkLoadTimeout(chunkLoadTimeout)\n  .crossOriginLoading(crossOriginLoading)\n  .devtoolFallbackModuleFilenameTemplate(devtoolFallbackModuleFilenameTemplate)\n  .devtoolLineToLine(devtoolLineToLine)\n  .devtoolModuleFilenameTemplate(devtoolModuleFilenameTemplate)\n  .devtoolNamespace(devtoolNamespace)\n  .filename(filename)\n  .hashFunction(hashFunction)\n  .hashDigest(hashDigest)\n  .hashDigestLength(hashDigestLength)\n  .hashSalt(hashSalt)\n  .hotUpdateChunkFilename(hotUpdateChunkFilename)\n  .hotUpdateFunction(hotUpdateFunction)\n  .hotUpdateMainFilename(hotUpdateMainFilename)\n  .jsonpFunction(jsonpFunction)\n  .library(library)\n  .libraryExport(libraryExport)\n  .libraryTarget(libraryTarget)\n  .path(path)\n  .pathinfo(pathinfo)\n  .publicPath(publicPath)\n  .sourceMapFilename(sourceMapFilename)\n  .sourcePrefix(sourcePrefix)\n  .strictModuleExceptionHandling(strictModuleExceptionHandling)\n  .umdNamedDefine(umdNamedDefine)\n```\n\n#### Config resolve: shorthand methods\n\n```js\nconfig.resolve : ChainedMap\n\nconfig.resolve\n  .cachePredicate(cachePredicate)\n  .cacheWithContext(cacheWithContext)\n  .enforceExtension(enforceExtension)\n  .enforceModuleExtension(enforceModuleExtension)\n  .unsafeCache(unsafeCache)\n  .symlinks(symlinks)\n```\n\n#### Config resolve alias\n\n```js\nconfig.resolve.alias : ChainedMap\n\nconfig.resolve.alias\n  .set(key, value)\n  .set(key, value)\n  .delete(key)\n  .clear()\n```\n\n#### Config resolve modules\n\n```js\nconfig.resolve.modules : ChainedSet\n\nconfig.resolve.modules\n  .add(value)\n  .prepend(value)\n  .clear()\n```\n\n#### Config resolve aliasFields\n\n```js\nconfig.resolve.aliasFields : ChainedSet\n\nconfig.resolve.aliasFields\n  .add(value)\n  .prepend(value)\n  .clear()\n```\n\n#### Config resolve descriptionFields\n\n```js\nconfig.resolve.descriptionFields : ChainedSet\n\nconfig.resolve.descriptionFields\n  .add(value)\n  .prepend(value)\n  .clear()\n```\n\n#### Config resolve extensions\n\n```js\nconfig.resolve.extensions : ChainedSet\n\nconfig.resolve.extensions\n  .add(value)\n  .prepend(value)\n  .clear()\n```\n\n#### Config resolve mainFields\n\n```js\nconfig.resolve.mainFields : ChainedSet\n\nconfig.resolve.mainFields\n  .add(value)\n  .prepend(value)\n  .clear()\n```\n\n#### Config resolve mainFiles\n\n```js\nconfig.resolve.mainFiles : ChainedSet\n\nconfig.resolve.mainFiles\n  .add(value)\n  .prepend(value)\n  .clear()\n```\n\n#### Config resolveLoader\n\nThe API for `config.resolveLoader` is identical to `config.resolve` with\nthe following additions:\n\n#### Config resolveLoader moduleExtensions\n\n```js\nconfig.resolveLoader.moduleExtensions : ChainedSet\n\nconfig.resolveLoader.moduleExtensions\n  .add(value)\n  .prepend(value)\n  .clear()\n```\n\n#### Config resolveLoader packageMains\n\n```js\nconfig.resolveLoader.packageMains : ChainedSet\n\nconfig.resolveLoader.packageMains\n  .add(value)\n  .prepend(value)\n  .clear()\n```\n\n#### Config performance: shorthand methods\n\n```js\nconfig.performance : ChainedMap\n\nconfig.performance\n  .hints(hints)\n  .maxEntrypointSize(maxEntrypointSize)\n  .maxAssetSize(maxAssetSize)\n  .assetFilter(assetFilter)\n```\n\n#### Configuring optimizations: shorthand methods\n\n```js\nconfig.optimization : ChainedMap\n\nconfig.optimization\n  .concatenateModules(concatenateModules)\n  .flagIncludedChunks(flagIncludedChunks)\n  .mergeDuplicateChunks(mergeDuplicateChunks)\n  .minimize(minimize)\n  .namedChunks(namedChunks)\n  .namedModules(namedModules)\n  .nodeEnv(nodeEnv)\n  .noEmitOnErrors(noEmitOnErrors)\n  .occurrenceOrder(occurrenceOrder)\n  .portableRecords(portableRecords)\n  .providedExports(providedExports)\n  .removeAvailableModules(removeAvailableModules)\n  .removeEmptyChunks(removeEmptyChunks)\n  .runtimeChunk(runtimeChunk)\n  .sideEffects(sideEffects)\n  .splitChunks(splitChunks)\n  .usedExports(usedExports)\n```\n\n#### Config optimization minimizers\n\n```js\n// Backed at config.optimization.minimizers\nconfig.optimization\n  .minimizer(name) : ChainedMap\n```\n\n#### Config optimization minimizers: adding\n\n_NOTE: Do not use `new` to create the minimizer plugin, as this will be done for you._\n\n```js\nconfig.optimization\n  .minimizer(name)\n  .use(WebpackPlugin, args)\n\n// Examples\n\nconfig.optimization\n  .minimizer('css')\n  .use(OptimizeCSSAssetsPlugin, [{ cssProcessorOptions: { safe: true } }])\n\n// Minimizer plugins can also be specified by their path, allowing the expensive require()s to be\n// skipped in cases where the plugin or webpack configuration won't end up being used.\nconfig.optimization\n  .minimizer('css')\n  .use(require.resolve('optimize-css-assets-webpack-plugin'), [{ cssProcessorOptions: { safe: true } }])\n\n```\n\n#### Config optimization minimizers: modify arguments\n\n```js\nconfig.optimization\n  .minimizer(name)\n  .tap(args =\u003e newArgs)\n\n// Example\nconfig.optimization\n  .minimizer('css')\n  .tap(args =\u003e [...args, { cssProcessorOptions: { safe: false } }])\n```\n\n#### Config optimization minimizers: modify instantiation\n\n```js\nconfig.optimization\n  .minimizer(name)\n  .init((Plugin, args) =\u003e new Plugin(...args));\n```\n\n#### Config optimization minimizers: removing\n\n```js\nconfig.optimization.minimizers.delete(name)\n```\n\n#### Config plugins\n\n```js\n// Backed at config.plugins\nconfig.plugin(name) : ChainedMap\n```\n\n#### Config plugins: adding\n\n_NOTE: Do not use `new` to create the plugin, as this will be done for you._\n\n```js\nconfig\n  .plugin(name)\n  .use(WebpackPlugin, args)\n\n// Examples\n\nconfig\n  .plugin('hot')\n  .use(webpack.HotModuleReplacementPlugin);\n\n// Plugins can also be specified by their path, allowing the expensive require()s to be\n// skipped in cases where the plugin or webpack configuration won't end up being used.\nconfig\n  .plugin('env')\n  .use(require.resolve('webpack/lib/EnvironmentPlugin'), [{ 'VAR': false }]);\n```\n\n#### Config plugins: modify arguments\n\n```js\nconfig\n  .plugin(name)\n  .tap(args =\u003e newArgs)\n\n// Example\nconfig\n  .plugin('env')\n  .tap(args =\u003e [...args, 'SECRET_KEY']);\n```\n\n#### Config plugins: modify instantiation\n\n```js\nconfig\n  .plugin(name)\n  .init((Plugin, args) =\u003e new Plugin(...args));\n```\n\n#### Config plugins: removing\n\n```js\nconfig.plugins.delete(name)\n```\n\n#### Config plugins: ordering before\n\nSpecify that the current `plugin` context should operate before another named\n`plugin`. You cannot use both `.before()` and `.after()` on the same plugin.\n\n```js\nconfig\n  .plugin(name)\n    .before(otherName)\n\n// Example\n\nconfig\n  .plugin('html-template')\n    .use(HtmlWebpackTemplate)\n    .end()\n  .plugin('script-ext')\n    .use(ScriptExtWebpackPlugin)\n    .before('html-template');\n```\n\n#### Config plugins: ordering after\n\nSpecify that the current `plugin` context should operate after another named\n`plugin`. You cannot use both `.before()` and `.after()` on the same plugin.\n\n```js\nconfig\n  .plugin(name)\n    .after(otherName)\n\n// Example\n\nconfig\n  .plugin('html-template')\n    .after('script-ext')\n    .use(HtmlWebpackTemplate)\n    .end()\n  .plugin('script-ext')\n    .use(ScriptExtWebpackPlugin);\n```\n\n#### Config resolve plugins\n\n```js\n// Backed at config.resolve.plugins\nconfig.resolve.plugin(name) : ChainedMap\n```\n\n#### Config resolve plugins: adding\n\n_NOTE: Do not use `new` to create the plugin, as this will be done for you._\n\n```js\nconfig.resolve\n  .plugin(name)\n  .use(WebpackPlugin, args)\n```\n\n#### Config resolve plugins: modify arguments\n\n```js\nconfig.resolve\n  .plugin(name)\n  .tap(args =\u003e newArgs)\n```\n\n#### Config resolve plugins: modify instantiation\n\n```js\nconfig.resolve\n  .plugin(name)\n  .init((Plugin, args) =\u003e new Plugin(...args))\n```\n\n#### Config resolve plugins: removing\n\n```js\nconfig.resolve.plugins.delete(name)\n```\n\n#### Config resolve plugins: ordering before\n\nSpecify that the current `plugin` context should operate before another named\n`plugin`. You cannot use both `.before()` and `.after()` on the same resolve\nplugin.\n\n```js\nconfig.resolve\n  .plugin(name)\n    .before(otherName)\n\n// Example\n\nconfig.resolve\n  .plugin('beta')\n    .use(BetaWebpackPlugin)\n    .end()\n  .plugin('alpha')\n    .use(AlphaWebpackPlugin)\n    .before('beta');\n```\n\n#### Config resolve plugins: ordering after\n\nSpecify that the current `plugin` context should operate after another named\n`plugin`. You cannot use both `.before()` and `.after()` on the same resolve\nplugin.\n\n```js\nconfig.resolve\n  .plugin(name)\n    .after(otherName)\n\n// Example\n\nconfig.resolve\n  .plugin('beta')\n    .after('alpha')\n    .use(BetaWebpackTemplate)\n    .end()\n  .plugin('alpha')\n    .use(AlphaWebpackPlugin);\n```\n\n#### Config node\n\n```js\nconfig.node : ChainedMap\n\nconfig.node\n  .set('__dirname', 'mock')\n  .set('__filename', 'mock');\n```\n\n#### Config devServer\n\n```js\nconfig.devServer : ChainedMap\n```\n\n#### Config devServer allowedHosts\n\n```js\nconfig.devServer.allowedHosts : ChainedSet\n\nconfig.devServer.allowedHosts\n  .add(value)\n  .prepend(value)\n  .clear()\n```\n\n#### Config devServer: shorthand methods\n\n```js\nconfig.devServer\n  .after(after)\n  .before(before)\n  .bonjour(bonjour)\n  .clientLogLevel(clientLogLevel)\n  .color(color)\n  .compress(compress)\n  .contentBase(contentBase)\n  .disableHostCheck(disableHostCheck)\n  .filename(filename)\n  .headers(headers)\n  .historyApiFallback(historyApiFallback)\n  .host(host)\n  .hot(hot)\n  .hotOnly(hotOnly)\n  .http2(http2)\n  .https(https)\n  .index(index)\n  .info(info)\n  .inline(inline)\n  .lazy(lazy)\n  .mimeTypes(mimeTypes)\n  .noInfo(noInfo)\n  .open(open)\n  .openPage(openPage)\n  .overlay(overlay)\n  .pfx(pfx)\n  .pfxPassphrase(pfxPassphrase)\n  .port(port)\n  .progress(progress)\n  .proxy(proxy)\n  .public(public)\n  .publicPath(publicPath)\n  .quiet(quiet)\n  .setup(setup)\n  .socket(socket)\n  .sockHost(sockHost)\n  .sockPath(sockPath)\n  .sockPort(sockPort)\n  .staticOptions(staticOptions)\n  .stats(stats)\n  .stdin(stdin)\n  .useLocalIp(useLocalIp)\n  .watchContentBase(watchContentBase)\n  .watchOptions(watchOptions)\n  .writeToDisk(writeToDisk)\n```\n\n#### Config module\n\n```js\nconfig.module : ChainedMap\n```\n\n#### Config module: shorthand methods\n\n```js\nconfig.module : ChainedMap\n\nconfig.module\n  .noParse(noParse)\n```\n\n#### Config module rules: shorthand methods\n\n```js\nconfig.module.rules : ChainedMap\n\nconfig.module\n  .rule(name)\n    .test(test)\n    .pre()\n    .post()\n    .enforce(preOrPost)\n```\n\n#### Config module rules uses (loaders): creating\n\n```js\nconfig.module.rules{}.uses : ChainedMap\n\nconfig.module\n  .rule(name)\n    .use(name)\n      .loader(loader)\n      .options(options)\n\n// Example\n\nconfig.module\n  .rule('compile')\n    .use('babel')\n      .loader('babel-loader')\n      .options({ presets: ['@babel/preset-env'] });\n```\n\n#### Config module rules uses (loaders): modifying options\n\n```js\nconfig.module\n  .rule(name)\n    .use(name)\n      .tap(options =\u003e newOptions)\n\n// Example\n\nconfig.module\n  .rule('compile')\n    .use('babel')\n      .tap(options =\u003e merge(options, {\n        plugins: ['@babel/plugin-proposal-class-properties']\n      }));\n```\n\n#### Config module rules nested rules:\n\n```js\nconfig.module.rules{}.rules : ChainedMap\u003cRule\u003e\n\nconfig.module\n  .rule(name)\n    .rule(name)\n\n// Example\n\nconfig.module\n  .rule('css')\n    .test(/\\.css$/)\n    .use('style')\n      .loader('style-loader')\n      .end()\n    .rule('postcss')\n      .resourceQuery(/postcss/)\n      .use('postcss')\n        .loader('postcss-loader')\n```\n\n#### Config module rules nested rules: ordering before\nSpecify that the current `rule` context should operate before another named\n`rule`. You cannot use both `.before()` and `.after()` on the same `rule`.\n\n```js\nconfig.module.rules{}.rules : ChainedMap\u003cRule\u003e\n\nconfig.module\n  .rule(name)\n    .rule(name)\n      .before(otherName)\n\n// Example\n\nconfig.module\n  .rule('css')\n    .use('style')\n      .loader('style-loader')\n      .end()\n    .rule('postcss')\n      .resourceQuery(/postcss/)\n      .use('postcss')\n        .loader('postcss-loader')\n        .end()\n      .end()\n    .rule('css-loader')\n      .resourceQuery(/css-loader/)\n      .before('postcss')\n      .use('css-loader')\n        .loader('css-loader')\n```\n\n#### Config module rules nested rules: ordering after\nSpecify that the current `rule` context should operate after another named\n`rule`. You cannot use both `.before()` and `.after()` on the same `rule`.\n\n```js\nconfig.module.rules{}.rules : ChainedMap\u003cRule\u003e\n\nconfig.module\n  .rule(name)\n    .rule(name)\n      .after(otherName)\n\n// Example\n\nconfig.module\n  .rule('css')\n    .use('style')\n      .loader('style-loader')\n      .end()\n    .rule('postcss')\n      .resourceQuery(/postcss/)\n      .after('css-loader')\n      .use('postcss')\n        .loader('postcss-loader')\n        .end()\n      .end()\n    .rule('css-loader')\n      .resourceQuery(/css-loader/)\n      .use('css-loader')\n        .loader('css-loader')\n```\n\n#### Config module rules oneOfs (conditional rules):\n\n```js\nconfig.module.rules{}.oneOfs : ChainedMap\u003cRule\u003e\n\nconfig.module\n  .rule(name)\n    .oneOf(name)\n\n// Example\n\nconfig.module\n  .rule('css')\n    .oneOf('inline')\n      .resourceQuery(/inline/)\n      .use('url')\n        .loader('url-loader')\n        .end()\n      .end()\n    .oneOf('external')\n      .resourceQuery(/external/)\n      .use('file')\n        .loader('file-loader')\n```\n\n#### Config module rules oneOfs (conditional rules): ordering before\nSpecify that the current `oneOf` context should operate before another named\n`oneOf`. You cannot use both `.before()` and `.after()` on the same `oneOf`.\n\n```js\nconfig.module\n  .rule(name)\n    .oneOf(name)\n      .before()\n\n// Example\n\nconfig.module\n  .rule('scss')\n    .test(/\\.scss$/)\n    .oneOf('normal')\n      .use('sass')\n        .loader('sass-loader')\n        .end()\n      .end()\n    .oneOf('sass-vars')\n      .before('normal')\n      .resourceQuery(/\\?sassvars/)\n      .use('sass-vars')\n        .loader('sass-vars-to-js-loader')\n```\n\n#### Config module rules oneOfs (conditional rules): ordering after\nSpecify that the current `oneOf` context should operate after another named\n`oneOf`. You cannot use both `.before()` and `.after()` on the same `oneOf`.\n\n```js\nconfig.module\n  .rule(name)\n    .oneOf(name)\n      .after()\n\n// Example\n\nconfig.module\n  .rule('scss')\n    .test(/\\.scss$/)\n    .oneOf('vue')\n      .resourceQuery(/\\?vue/)\n      .use('vue-style')\n        .loader('vue-style-loader')\n        .end()\n      .end()\n    .oneOf('normal')\n      .use('sass')\n        .loader('sass-loader')\n        .end()\n      .end()\n    .oneOf('sass-vars')\n      .after('vue')\n      .resourceQuery(/\\?sassvars/)\n      .use('sass-vars')\n        .loader('sass-vars-to-js-loader')\n```\n\n#### Config module rules resolve\n\nSpecify a resolve configuration to be merged over the default `config.resolve`\nfor modules that match the rule.\n\nSee \"Config resolve\" sections above for full syntax.\n\n**Note:** This option is supported by webpack since 4.36.1.\n\n```js\nconfig.module\n  .rule(name)\n    .resolve\n\n// Example\n\nconfig.module\n  .rule('scss')\n    .test(/\\.scss$/)\n    .resolve\n      .symlinks(true)\n```\n\n---\n\n### Merging Config\n\nwebpack-chain supports merging in an object to the configuration instance which\nmatches a layout similar to how the webpack-chain schema is laid out.\n\n**Note:** This object does not match the webpack configuration schema exactly\n(for example the `[name]` keys for entry/rules/plugins), so you may need to transform\nwebpack configuration objects (such as those output by webpack-chain's `.toConfig()`)\nto match the layout below prior to passing to `.merge()`.\n\n```js\nconfig.merge({ devtool: 'source-map' });\n\nconfig.get('devtool') // \"source-map\"\n```\n\n```js\nconfig.merge({\n  [key]: value,\n\n  amd,\n  bail,\n  cache,\n  context,\n  devtool,\n  externals,\n  loader,\n  mode,\n  parallelism,\n  profile,\n  recordsPath,\n  recordsInputPath,\n  recordsOutputPath,\n  stats,\n  target,\n  watch,\n  watchOptions,\n\n  entry: {\n    [name]: [...values]\n  },\n\n  plugin: {\n    [name]: {\n      plugin: WebpackPlugin,\n      args: [...args],\n      before,\n      after\n    }\n  },\n\n  devServer: {\n    [key]: value,\n\n    clientLogLevel,\n    compress,\n    contentBase,\n    filename,\n    headers,\n    historyApiFallback,\n    host,\n    hot,\n    hotOnly,\n    https,\n    inline,\n    lazy,\n    noInfo,\n    overlay,\n    port,\n    proxy,\n    quiet,\n    setup,\n    stats,\n    watchContentBase\n  },\n\n  node: {\n    [key]: value\n  },\n\n  optimization: {\n    concatenateModules,\n    flagIncludedChunks,\n    mergeDuplicateChunks,\n    minimize,\n    minimizer: {\n      [name]: {\n        plugin: WebpackPlugin,\n        args: [...args],\n        before,\n        after\n      }\n    },\n    namedChunks,\n    namedModules,\n    nodeEnv,\n    noEmitOnErrors,\n    occurrenceOrder,\n    portableRecords,\n    providedExports,\n    removeAvailableModules,\n    removeEmptyChunks,\n    runtimeChunk,\n    sideEffects,\n    splitChunks,\n    usedExports,\n  },\n\n  performance: {\n    [key]: value,\n\n    hints,\n    maxEntrypointSize,\n    maxAssetSize,\n    assetFilter\n  },\n\n  resolve: {\n    [key]: value,\n\n    alias: {\n      [key]: value\n    },\n    aliasFields: [...values],\n    descriptionFields: [...values],\n    extensions: [...values],\n    mainFields: [...values],\n    mainFiles: [...values],\n    modules: [...values],\n\n    plugin: {\n      [name]: {\n        plugin: WebpackPlugin,\n        args: [...args],\n        before,\n        after\n      }\n    }\n  },\n\n  resolveLoader: {\n    [key]: value,\n\n    alias: {\n      [key]: value\n    },\n    aliasFields: [...values],\n    descriptionFields: [...values],\n    extensions: [...values],\n    mainFields: [...values],\n    mainFiles: [...values],\n    modules: [...values],\n    moduleExtensions: [...values],\n    packageMains: [...values],\n\n    plugin: {\n      [name]: {\n        plugin: WebpackPlugin,\n        args: [...args],\n        before,\n        after\n      }\n    }\n  },\n\n  module: {\n    [key]: value,\n\n    rule: {\n      [name]: {\n        [key]: value,\n\n        enforce,\n        issuer,\n        parser,\n        resource,\n        resourceQuery,\n        test,\n\n        include: [...paths],\n        exclude: [...paths],\n\n        rules: {\n          [name]: Rule\n        },\n\n        oneOf: {\n          [name]: Rule\n        },\n\n        use: {\n          [name]: {\n            loader: LoaderString,\n            options: LoaderOptions,\n            before,\n            after\n          }\n        }\n      }\n    }\n  }\n})\n```\n\n### Conditional configuration\n\nWhen working with instances of `ChainedMap` and `ChainedSet`, you can perform\nconditional configuration using `when`. You must specify an expression to\n`when()` which will be evaluated for truthiness or falsiness. If the expression\nis truthy, the first function argument will be invoked with an instance of the\ncurrent chained instance. You can optionally provide a second function to be\ninvoked when the condition is falsy, which is also given the current chained\ninstance.\n\n```js\n// Example: Only add minify plugin during production\nconfig\n  .when(process.env.NODE_ENV === 'production', config =\u003e {\n    config\n      .plugin('minify')\n      .use(BabiliWebpackPlugin);\n  });\n```\n\n```js\n// Example: Only add minify plugin during production,\n// otherwise set devtool to source-map\nconfig\n  .when(process.env.NODE_ENV === 'production',\n    config =\u003e config.plugin('minify').use(BabiliWebpackPlugin),\n    config =\u003e config.devtool('source-map')\n  );\n```\n\n### Inspecting generated configuration\n\nYou can inspect the generated webpack config using `config.toString()`. This\nwill generate a stringified version of the config with comment hints for named\nrules, uses and plugins:\n\n```js\nconfig\n  .module\n    .rule('compile')\n      .test(/\\.js$/)\n      .use('babel')\n        .loader('babel-loader');\n\nconfig.toString();\n\n/*\n{\n  module: {\n    rules: [\n      /* config.module.rule('compile') */\n      {\n        test: /\\.js$/,\n        use: [\n          /* config.module.rule('compile').use('babel') */\n          {\n            loader: 'babel-loader'\n          }\n        ]\n      }\n    ]\n  }\n}\n*/\n```\n\nBy default the generated string cannot be used directly as real webpack config\nif it contains objects and plugins that need to be required. In order to\ngenerate usable config, you can customize how objects and plugins are\nstringified by setting a special `__expression` property on them:\n\n```js\nconst sass = require('sass');\nsass.__expression = `require('sass')`;\n\nclass MyPlugin {}\nMyPlugin.__expression = `require('my-plugin')`;\n\nfunction myFunction () {}\nmyFunction.__expression = `require('my-function')`;\n\nconfig\n  .plugin('example')\n    .use(MyPlugin, [{ fn: myFunction, implementation: sass, }]);\n\nconfig.toString();\n\n/*\n{\n  plugins: [\n    new (require('my-plugin'))({\n      fn: require('my-function'),\n      implementation: require('sass')\n    })\n  ]\n}\n*/\n```\n\nPlugins specified via their path will have their `require()` statement generated\nautomatically:\n\n```js\nconfig\n  .plugin('env')\n    .use(require.resolve('webpack/lib/ProvidePlugin'), [{ jQuery: 'jquery' }])\n\nconfig.toString();\n\n/*\n{\n  plugins: [\n    new (require('/foo/bar/src/node_modules/webpack/lib/EnvironmentPlugin.js'))(\n      {\n        jQuery: 'jquery'\n      }\n    )\n  ]\n}\n*/\n```\n\nYou can also call `toString` as a static method on `Config` in order to\nmodify the configuration object prior to stringifying.\n\n```js\nConfig.toString({\n  ...config.toConfig(),\n  module: {\n    defaultRules: [\n      {\n        use: [\n          {\n            loader: 'banner-loader',\n            options: { prefix: 'banner-prefix.txt' },\n          },\n        ],\n      },\n    ],\n  },\n})\n```\n\n```\n{\n  plugins: [\n    /* config.plugin('foo') */\n    new TestPlugin()\n  ],\n  module: {\n    defaultRules: [\n      {\n        use: [\n          {\n            loader: 'banner-loader',\n            options: {\n              prefix: 'banner-prefix.txt'\n            }\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n[npm-image]: https://img.shields.io/npm/v/webpack-chain.svg\n[npm-downloads]: https://img.shields.io/npm/dt/webpack-chain.svg\n[npm-url]: https://www.npmjs.com/package/webpack-chain\n[ci-image]: https://github.com/neutrinojs/webpack-chain/actions/workflows/ci.yml/badge.svg\n[ci-url]: https://github.com/neutrinojs/webpack-chain/actions/workflows/ci.yml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneutrinojs%2Fwebpack-chain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneutrinojs%2Fwebpack-chain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneutrinojs%2Fwebpack-chain/lists"}