unplugin-vue-named-export
v0.5.0
Published
Named export for Vue SFC.
Downloads
19
Readme
unplugin-vue-named-export
Named export for Vue SFC.
Installation
npm i -D unplugin-vue-named-export
// vite.config.ts
import VueNamedExport from 'unplugin-vue-named-export/vite'
export default defineConfig({
plugins: [
VueNamedExport({
/* options */
}),
],
})
// rollup.config.js
import VueNamedExport from 'unplugin-vue-named-export/rollup'
export default {
plugins: [
VueNamedExport({
/* options */
}),
],
}
// esbuild.config.js
import { build } from 'esbuild'
build({
plugins: [
require('unplugin-vue-named-export/esbuild')({
/* options */
}),
],
})
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-vue-named-export/webpack')({
/* options */
}),
],
}
Usage
Use pascal case named exports in Vue SFC.
import { MyFooter } from './my_footer.vue'
import { MyCard } from './my-card.vue'
import { MyComponent } from './MyComponent.vue'
Options
type Options = {
include?: string | RegExp | (string | RegExp)[]
exclude?: string | RegExp | (string | RegExp)[]
/**
* Convert filename to export name
* @default pascalCaseFn
*/
resolveName?: (id: string) => string | Promise<string>
/**
* Whether to keep default export
* @default false
*/
removeDefault?: boolean
}
Vue Language Tools (Volar)
For Vue Language Tools (Volar) < 2.0, please use [email protected]
Support only pascal case named export for Volar.
// tsconfig.json
{
// ...
"vueCompilerOptions": {
"plugins": ["unplugin-vue-named-export/volar"],
"namedExport": {
// defaults to false
"removeDefault": false,
},
},
}