Named export for Vue SFC.
npm install unplugin-vue-named-export[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Unit Test][unit-test-src]][unit-test-href]
Named export for Vue SFC.
``bash`
npm i -D unplugin-vue-named-export
Vite
`ts
// vite.config.ts
import VueNamedExport from 'unplugin-vue-named-export/vite'
export default defineConfig({
plugins: [
VueNamedExport({
/ options /
}),
],
})
`
Rollup
`ts
// rollup.config.js
import VueNamedExport from 'unplugin-vue-named-export/rollup'
export default {
plugins: [
VueNamedExport({
/ options /
}),
],
}
`
esbuild
`ts
// esbuild.config.js
import { build } from 'esbuild'
build({
plugins: [
require('unplugin-vue-named-export/esbuild')({
/ options /
}),
],
})
`
Webpack
`ts`
// webpack.config.js
module.exports = {
/ ... /
plugins: [
require('unplugin-vue-named-export/webpack')({
/ options /
}),
],
}
Use pascal case named exports in Vue SFC.
`ts`
import { MyCard } from './my-card.vue'
import { MyFooter } from './my_footer.vue'
import { MyComponent } from './MyComponent.vue'
`ts
type Options = {
include?: string | RegExp | (string | RegExp)[]
exclude?: string | RegExp | (string | RegExp)[]
/**
* Convert filename to export name
* @default pascalCaseFn
*/
resolveName?: (id: string) => string | Promise
/**
* Whether to remove default export
* @default false
*/
removeDefault?: boolean
}
`
For Vue Language Tools (Volar) < 2.0, please use unplugin-vue-named-export@0.3.0
Support only pascal case named export for Volar.
`jsonc
// tsconfig.json
{
// ...
"vueCompilerOptions": {
"plugins": ["unplugin-vue-named-export/volar"],
"namedExport": {
// defaults to false
"removeDefault": false,
},
},
}
``
MIT License © 2023-PRESENT Kevin Deng
[npm-version-src]: https://img.shields.io/npm/v/unplugin-vue-named-export.svg
[npm-version-href]: https://npmjs.com/package/unplugin-vue-named-export
[npm-downloads-src]: https://img.shields.io/npm/dm/unplugin-vue-named-export
[npm-downloads-href]: https://www.npmcharts.com/compare/unplugin-vue-named-export?interval=30
[unit-test-src]: https://github.com/sxzz/unplugin-vue-named-export/actions/workflows/unit-test.yml/badge.svg
[unit-test-href]: https://github.com/sxzz/unplugin-vue-named-export/actions/workflows/unit-test.yml