Skip to content

ExternalVitePlugin

data class ExternalVitePlugin(
    val exportedAs: String, 
    val packageName: String, 
    val version: String, 
    val configuration: String? = null, 
    val isNamedExport: Boolean = false, 
    val isLocal: Boolean = false
) : Serializable

An external plugin for Vite downloaded via NPM.

Multiple lists of plugins are available:

Examples

To understand how to create an instance of this class, read the configuration example provided by the plugin. Generally, a plugin is installed like so:

// vite.config.js

import vue from '@vitejs/plugin-vue'

export default {
    plugins: [vue()],
}

The declaration should be:

ExternalVitePlugin(
    exportedAs = "vue",
    packageName = "@vitejs/plugin-vue",
    version = "4.1.0",
)

If additional configuration is needed, for example like so:

// vite.config.js
import vue from '@vitejs/plugin-vue'

export default {
  plugins: [
    vue({
      template: {
        compilerOptions: {
          // ...
        },
      },
    }),
  ],
}

The declaration should be:

ExternalVitePlugin(
    exportedAs = "vue",
    packageName = "@vitejs/plugin-vue",
    version = "4.1.0",
    configuration = """
        {
            template: {
                compilerOptions: {
                    // ...
                }
            }
        }
    """.trimIndent()
)

Constructors

ExternalVitePlugin

constructor(
    exportedAs: String, 
    packageName: String, 
    version: String, 
    configuration: String? = null, 
    isNamedExport: Boolean = false, 
    isLocal: Boolean = false
)

Properties

configuration

Any additional configuration provided to the plugin.

exportedAs

The name of the function exported by this plugin.

For example, for the Vue plugin, which is natively configured like so:

import vue from '@vitejs/plugin-vue'

export default {
    plugins: [vue()],
}

the exportedAs is vue.

isLocal

If true, the plugin dependency will not be added to the package.json file. In this case, it is assumed that the packageName contains a local path.

isNamedExport

If true, the configuration will be generated as import {name} from 'foo', whereas if false the configuration will be generated as import name from 'foo'.

packageName

The name of the NPM package which contains this plugin.

For example, for the Vue plugin, which is natively configured like so:

import vue from '@vitejs/plugin-vue'

export default {
    plugins: [vue()],
}

the packageName is @vitejs/plugin-vue.

version

The version of the project, as it appears on NPM.

Functions

toString

open override fun toString(): String