unplugin-auto-re-export
v0.2.1
Published
Unified utils for auto generate re-export file.
Downloads
25
Maintainers
Readme
unplugin-auto-re-export
Auto generate re-export file for Vite, Webpack, Rollup and more. Powered by unplugin.
If you have some files like
// utils/func.js
export function foo() {
/* ... */
}
// utils/types.js
export const bar = 1;
the plugin can generate a file to re-export
// utils/index.js
export { foo } from "./func";
export { bar } from "./types";
by options
autoReExportPlugin({
dir: ["utils"],
});
and modify when watched files change.
Install
npm i -D unplugin-auto-re-export
Usage
// vite.config.ts
import autoReExportPlugin from "unplugin-auto-re-export/vite";
export default defineConfig({
plugins: [
autoReExportPlugin({
/* options */
}),
],
});
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require("unplugin-auto-re-export/webpack")({
/* options */
}),
],
};
// rollup.config.js
import autoReExportPlugin from "unplugin-auto-re-export/rollup";
export default {
plugins: [
autoReExportPlugin({
/* options */
}),
],
};
Options
| Key | Type | Default | Description |
| ------------- | ------------------------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------ |
| dir | string \| string[] \| DirConfig[]
| []
| An array of watched directory path |
| ignore | string[]
| []
| An array of file path to exclude watched file |
| outputFile | string
| index.js
| Define the outputfile name and extension name |
| exportAll | boolean
| false
| Is spread all exports with export * from "mod"
|
| deep | number
| Infinity
| Specifies the maximum depth of a read directory relative to the start directory |
| baseNameMatch | string
| *
| The pattern to match basename. See pattern-syntax |
DirConfig
type DirConfig = {
path: string;
exportAll?: boolean;
deep?: number;
baseNameMatch?: string;
};