1.0.0 • Published 6 months ago

rollup-plugin-file-resolve v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

rollup-plugin-file-resolve

Rollup plugin to resolve files with custom loaders at build time.

Installation

npm:

npm i rollup-plugin-file-resolve -D

yarn:

yarn add rollup-plugin-file-resolve -D

pnpm:

pnpm add rollup-plugin-file-resolve -D

Usage

Checkout the Example

Options

[alias]

Type: text | object

Determines from where to resolve the specific file.

Available built-in loaders: text

For example:

{
  // Resolve `lmao` from `library.js`
  lmao: "project/library.js",

  // Resolve `myo` from `file.txt` and import it as a string
  myo: {
    path: "project/file.txt",
    loader: "text"
  }
}

Example output:

var lmao = "Random ahh file";

function myo(text) {
  console.log(text);
}

Custom loaders

Using your own custom loader is very simple, just replace the loader prop with a function.

Here is an example:

myo: {
  path: "project/file.txt",
  loader: async (code) => await transform(code)
}

The loader function can be both sync or async.

Exports

loaders

Returns: Object of default loaders:

{
  text: (code) => code;
}

Information

Resources

Made by Angelo II

Copyright © (C) Angelo II, MIT license.

1.0.0

6 months ago