https://github.com/unplugin/unplugin-vue-named-export
Named export for Vue SFC.
https://github.com/unplugin/unplugin-vue-named-export
Last synced: 8 months ago
JSON representation
Named export for Vue SFC.
- Host: GitHub
- URL: https://github.com/unplugin/unplugin-vue-named-export
- Owner: unplugin
- License: mit
- Created: 2023-03-09T15:41:46.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-12T02:54:49.000Z (8 months ago)
- Last Synced: 2025-04-12T03:34:29.343Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 825 KB
- Stars: 21
- Watchers: 1
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# unplugin-vue-named-export [](https://npmjs.com/package/unplugin-vue-named-export)
[](https://github.com/unplugin/unplugin-vue-named-export/actions/workflows/unit-test.yml)
Named export for Vue SFC.
## Installation
```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 */
}),
],
}
```
## Usage
Use pascal case named exports in Vue SFC.
```ts
import { MyFooter } from './my_footer.vue'
import { MyCard } from './my-card.vue'
import { MyComponent } from './MyComponent.vue'
```
### Options
```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
}
```
### Vue Language Tools (Volar)
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,
},
},
}
```
## Sponsors
## License
[MIT](./LICENSE) License © 2023-PRESENT [三咲智子](https://github.com/sxzz)