# @macropygia/vite-plugin-glob-input

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

Latest version **0.0.18** (published 2024-06-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @macropygia/vite-plugin-glob-input
pnpm add @macropygia/vite-plugin-glob-input
yarn add @macropygia/vite-plugin-glob-input
bun add @macropygia/vite-plugin-glob-input
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.18 |
| Published | 2024-06-01 |
| First published | 2022-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | macropygia |
| Maintainers | macropygia |
| Keywords | vite, vite-plugin, static, glob |

## Links

- npm: https://www.npmjs.com/package/@macropygia/vite-plugin-glob-input
- Repository: https://github.com/macropygia/static-site-stack
- Homepage: https://github.com/macropygia/static-site-stack/tree/main/packages/vite-plugin-glob-input#readme
- Issues: https://github.com/macropygia/static-site-stack/issues
- npm.io page: https://npm.io/package/@macropygia/vite-plugin-glob-input

## Dependencies (1)

- [fast-glob](https://npm.io/package/fast-glob.md) ^3.3.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.18 (latest) — 2024-06-01
- 0.0.17 — 2024-03-19
- 0.0.16 — 2022-12-23
- 0.0.15 — 2022-08-01
- 0.0.14 — 2022-07-21
- 0.0.13 — 2022-07-15
- 0.0.12 — 2022-07-06
- 0.0.11 — 2022-07-06
- 0.0.10 — 2022-06-25
- 0.0.9 — 2022-06-11
- 0.0.8 — 2022-06-08
- 0.0.7 — 2022-06-01
- 0.0.6 — 2022-05-30
- 0.0.5 — 2022-05-28
- 0.0.4 — 2022-05-25
- … 3 more at https://npm.io/package/@macropygia/vite-plugin-glob-input/versions

## README

# @macropygia/vite-plugin-glob-input

[![npm version](https://img.shields.io/npm/v/@macropygia/vite-plugin-glob-input.svg?style=flat-square)](https://www.npmjs.com/package/@macropygia/vite-plugin-glob-input)
[![MIT](https://img.shields.io/npm/l/@macropygia/vite-plugin-glob-input?style=flat-square)](./LICENSE)
[![TypeScript](https://img.shields.io/badge/TypeScript-3178c6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![Vite](https://img.shields.io/badge/Vite-646cff?style=flat-square&logo=Vite&logoColor=white)](https://vitejs.dev/)

**English** | [日本語](README.ja_JP.md)

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](CHANGELOG.md) for changes.
- This package [only works as ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
    - `"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

```js
// 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](https://github.com/mrmlnc/fast-glob#pattern-syntax)

### options

- Same as the fast-glob options.
    - `options.absolute` is forced to be `true` .
- Ref. [Options - fast-glob](https://github.com/mrmlnc/fast-glob#options-3)

### 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

---
_Source: https://npm.io/package/@macropygia/vite-plugin-glob-input · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
