vite-plugin-vue-component-name-checker
TypeScript icon, indicating that this package has built-in type declarations

0.1.14 • Public • Published

vite-plugin-vue-component-name-checker

A vite pulgin to check if name of a component incorrect. Currently only supporting checking name in script attrs or defineOptions

For example

<script setup name="aaa"></script>

<script setup>
    defineOptions({
        name: 'aaa',
    });
</script>

When using vite-plugin-pages, we must name vue components correctly to work with keep-alive, the default regular of this plugin is check if vue files correctly be named using vite-plugin-pages's filesystem routes.

Install

pnpm add -D vite-plugin-vue-component-name-checker

npm i -D vite-plugin-vue-component-name-checker

yarn add -D vite-plugin-vue-component-name-checker

Usage

import VueComponentNameChecker from './vite-plugins/vite-plugin-vue-component-name-checker';

export default defineConfig({
    plugins: [
        VueComponentNameChecker({
            dir: path.join(__dirname, 'src', 'pages'),
            exclude: ['/modules'],
        }),
    ],
});

Options

// root directory
dir: string
// vue file path which includes strings in exlude will be ignored
exclude?: string[]
// format component name if you want to use a special way to check component name
// id is the path of current module, you should return what you want which will be compared with name in defineOptions or name='xxx' in script setup attr.
regular?: (id: string) => string;

/vite-plugin-vue-component-name-checker/

    Package Sidebar

    Install

    npm i vite-plugin-vue-component-name-checker

    Weekly Downloads

    2

    Version

    0.1.14

    License

    ISC

    Unpacked Size

    11.7 kB

    Total Files

    6

    Last publish

    Collaborators

    • buildstrap