mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +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.
|
||||
*/
|
||||
export function addWebpackPlugin (plugin: WebpackPluginInstance, options?: ExtendWebpackConfigOptions) {
|
||||
export function addWebpackPlugin (plugin: WebpackPluginInstance | WebpackPluginInstance[], options?: ExtendWebpackConfigOptions) {
|
||||
extendWebpackConfig((config) => {
|
||||
config.plugins = config.plugins || []
|
||||
config.plugins.push(plugin)
|
||||
if (Array.isArray(plugin)) {
|
||||
config.plugins.push(...plugin)
|
||||
} else {
|
||||
config.plugins.push(plugin)
|
||||
}
|
||||
}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Append Vite plugin to the config.
|
||||
*/
|
||||
export function addVitePlugin (plugin: VitePlugin, options?: ExtendViteConfigOptions) {
|
||||
export function addVitePlugin (plugin: VitePlugin | VitePlugin[], options?: ExtendViteConfigOptions) {
|
||||
extendViteConfig((config) => {
|
||||
config.plugins = config.plugins || []
|
||||
config.plugins.push(plugin)
|
||||
if (Array.isArray(plugin)) {
|
||||
config.plugins.push(...plugin)
|
||||
} else {
|
||||
config.plugins.push(plugin)
|
||||
}
|
||||
}, options)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user