# rollup-plugin-glob-import **Repository Path**: xxXyh1908/rollup-plugin-glob-import ## Basic Information - **Project Name**: rollup-plugin-glob-import - **Description**: A rollup-plugin to use glob-star. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-31 - **Last Updated**: 2022-05-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Version rollup License: MIT # [🏠 @xyh19/rollup-plugin-glob-import](https://gitee.com/xxXyh1908/rollup-plugin-glob-import/#readme)
A rollup-plugin to use glob-star.
## install ```bash npm install -D @xyh19/rollup-plugin-glob-import # or yarn add -D @xyh19/rollup-plugin-glob-import ``` ## Getting Started Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin: ```js // rollup.config.js import globImport from '@xyh19/rollup-plugin-glob-import' import path from 'path' export default { input: 'src/index.js', output: { dir: 'output', format: 'cjs', }, plugins: [ globImport({ globConfigs: [ { loader: 'default', glob: 'src/components/*', aliases: '~components', dynamicImport: false, moduleIdRenamer: (filename) => path.parse(filename).name, moduleKeyRenamer: (filename) => path.parse(filename).name, }, { loader: 'vue-routes', glob: 'src/page/**/*.vue', aliases: '~routes', moduleIdRenamer: (filename) => path.parse(filename).name, moduleKeyRenamer: (filename) => path.parse(filename).name, }, ], }), ], } ``` Import virtual module: ```js // src/components/a.js export default 'components-a'; // src/components/b.js export default 'components-b'; // src/index.js import * as components from '~components'; console.log(components) // { a: 'components-a', b: 'components-b'} ``` ## Options ### `globConfigs` Type: `GlobConfig | GlobConfig[]`
glob-import configs. ### `exclude` Type: `string | string[]`
Default: `null` A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. ### `defaultLoader` Type: `'import' | 'default' | 'named' | 'namedModule' | 'mixed' | 'vue-routes' | 'react-routes' | Loader`
A function generator for module export. ## GlobConfig ### `aliases` Type: `string | string[]`
Default: `null` Provide the virtual ID of the imported module. ### `glob` Type: `string`
Glob expression to import. ### `exclude` Type: `string | string[]`
Default: `null` A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. ### `transform` Type: `TransformHook`
## Show your support Give a ⭐️ if this project helped you!