@macropygia/vite-plugin-glob-input
v0.0.18
Published
Vite plugin to add files to build.rollupOptions.input using fast-glob
Downloads
36
Maintainers
Readme
@macropygia/vite-plugin-glob-input
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
- Same as the fast-glob patterns
- Ref. Pattern syntax - fast-glob
options
- Same as the fast-glob options.
options.absolute
is forced to betrue
.
- Ref. Options - fast-glob
disableAlias
- Disable alias auto-generation.
- Change type of
build.rollupOptions.input
tostring[]
.
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