npm.io
0.0.18 • Published 2 years ago

@macropygia/vite-plugin-glob-input

Licence
MIT
Version
0.0.18
Deps
1
Size
11 kB
Vulns
0
Weekly
0
Stars
6

@macropygia/vite-plugin-glob-input

npm version MIT TypeScript Vite

English | 日本語

Vite plugin to add files to build.rollupOptions.input using fast-glob.

  • This package is currently unstable.
    • Breaking changes may occur without any notice, even if in patch releases.
    • See CHANGELOG for changes.
  • This package only works as ESM.
    • "type": "module" is required in the package.json of the project using this plugin.
  • Suitable for a traditional static site.
  • Auto-generate alias from directory and file name.
    • /index.html -> home
    • /foo.html -> root_foo
    • /foo/index.html -> foo
    • /foo/bar.html -> foo_bar
  • Merge build.rollupOptions.input if it already exists.
    • Except string
    • No duplicate check

Usage

// vite.config.js
import { defineConfig } from 'vite'
import vitePluginGlobInput from '@macropygia/vite-plugin-glob-input'

export default defineConfig({
  plugins: [
    vitePluginGlobInput({
      patterns: 'src/**/*.html',
    }),
  ],
})

Options

Parameter Type Default Required
patterns string | string[] Yes
options object No
disableAlias boolean false No
homeAlias string home No
rootPrefix string root No
dirDelimiter string - No
filePrefix string _ No
patterns
options
  • Same as the fast-glob options.
    • options.absolute is forced to be true .
  • Ref. Options - fast-glob
disableAlias
  • Disable alias auto-generation.
  • Change type of build.rollupOptions.input to string[].
homeAlias

Alias for index in root directory.

/index.html -> home

rootPrefix

Alias for root directory. It will use when the root directory has non-index files.

/foo.html -> root_foo

dirDelimiter

Delimiter for joining directory names.

/foo/bar/index.html -> foo-bar

filePrefix

Prefix for non-index files.

/foo/bar/baz.html -> foo-bar_baz

Keywords