mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
feat(kit): support plugin array for addVitePlugin
and addWebpackPlugin
(#8270)
This commit is contained in:
parent
b1c842e8be
commit
6567ac375d
@ -117,19 +117,27 @@ export function extendViteConfig (
|
|||||||
/**
|
/**
|
||||||
* Append Webpack plugin to the config.
|
* Append Webpack plugin to the config.
|
||||||
*/
|
*/
|
||||||
export function addWebpackPlugin (plugin: WebpackPluginInstance, options?: ExtendWebpackConfigOptions) {
|
export function addWebpackPlugin (plugin: WebpackPluginInstance | WebpackPluginInstance[], options?: ExtendWebpackConfigOptions) {
|
||||||
extendWebpackConfig((config) => {
|
extendWebpackConfig((config) => {
|
||||||
config.plugins = config.plugins || []
|
config.plugins = config.plugins || []
|
||||||
config.plugins.push(plugin)
|
if (Array.isArray(plugin)) {
|
||||||
|
config.plugins.push(...plugin)
|
||||||
|
} else {
|
||||||
|
config.plugins.push(plugin)
|
||||||
|
}
|
||||||
}, options)
|
}, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append Vite plugin to the config.
|
* Append Vite plugin to the config.
|
||||||
*/
|
*/
|
||||||
export function addVitePlugin (plugin: VitePlugin, options?: ExtendViteConfigOptions) {
|
export function addVitePlugin (plugin: VitePlugin | VitePlugin[], options?: ExtendViteConfigOptions) {
|
||||||
extendViteConfig((config) => {
|
extendViteConfig((config) => {
|
||||||
config.plugins = config.plugins || []
|
config.plugins = config.plugins || []
|
||||||
config.plugins.push(plugin)
|
if (Array.isArray(plugin)) {
|
||||||
|
config.plugins.push(...plugin)
|
||||||
|
} else {
|
||||||
|
config.plugins.push(plugin)
|
||||||
|
}
|
||||||
}, options)
|
}, options)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user