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