rollup-plugin-auto-import

0.0.12 • Public • Published

rollup-plugin-auto-import

A Rollup plugin which can use utils or npm package direct, this plugin will import them underground

Install

Using npm:

npm install rollup-plugin-auto-import --save-dev

Usage

Create a rollup.config.js configuration file and import the plugin:

import autoImport from 'rollup-plugin-auto-import';
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [
    resolve(),
    autoImport({
        exclude: [/\.less\b/], // !! exclude unnecessary file
        inject: {
            vue: ['ref'],
        },
    }),
    typescript({
        target: 'es5',
    }),
  ]
};

Then call rollup either via the CLI or the API.

Options

In addition to the properties and values specified for replacement, users may also specify the options below.

presetDir

Type: String
Default: auto-import

specify he directory loaded by default, the content exposed inside can be used directly.

inject

Type: { [key: string]: Array[...string] }
Default: {}

Specify the third party module to be loaded.

exclude

Type: String | Array[...String]
Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.

include

Type: String | Array[...String]
Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.

Package Sidebar

Install

npm i rollup-plugin-auto-import

Weekly Downloads

0

Version

0.0.12

License

MIT

Unpacked Size

138 kB

Total Files

5

Last publish

Collaborators

  • cnfox