Object | Function | undefined
undefined
only support webpack
tools.webpack
is used to configure webpack.
tools.bundlerChain
is also used to modify the webpack configuration, and the function is more powerful. It is recommended to usetools.bundlerChain
first.
tools.webpack
can be configured as an object to be deep merged with the built-in webpack configuration through webpack-merge.
For example, add resolve.alias
configuration:
tools.webpack
can be configured as a function. The first parameter of this function is the built-in webpack configuration object, you can modify this object, and then return it. For example:
The object returned by the tools.webpack
function is used directly as the final webpack configuration and is not merged with the built-in webpack configuration.
The second parameter of this function is an object, which contains some utility functions and properties, as follows:
'development' | 'production' | 'test'
The env
parameter can be used to determine whether the current environment is development, production or test. For example:
boolean
The isProd
parameter can be used to determine whether the current environment is production. For example:
'web' | 'node' | 'modern-web' | 'web-worker'
The target
parameter can be used to determine the current target. For example:
boolean
Determines whether the target environment is node
, equivalent to target === 'node'
.
boolean
Determines whether the target environment is web-worker
, equivalent to target === 'web-worker'
.
typeof import('webpack')
The webpack instance. For example:
typeof import('html-webpack-plugin')
The HtmlWebpackPlugin instance:
(rules: RuleSetRule | RuleSetRule[]) => void
Add additional webpack rules.
For example:
(plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void
Add additional plugins to the head of the internal webpack plugins array, and the plugin will be executed first.
(plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void
Add additional plugins at the end of the internal webpack plugins array, the plugin will be executed last.
(name: string) => void
Remove the internal webpack plugin, the parameter is the constructor.name
of the plugin.
For example, remove the internal fork-ts-checker-webpack-plugin:
(...configs: WebpackConfig[]) => WebpackConfig
Used to merge multiple webpack configs, same as webpack-merge.