4.1.1 • Published 1 month ago

rollup-plugin-external-assets v4.1.1

Weekly downloads
137
License
MIT
Repository
github
Last release
1 month ago

npm npm build codecov MIT license

rollup-plugin-external-assets

A rollup plugin to make assets external, they will not be added to the bundling pipeline, but they will still be included in the final output.

Installation

Via npm

npm install --save-dev rollup-plugin-external-assets

Via yarn

yarn add -D rollup-plugin-external-assets

Usage

Assuming a src/index.js exists and contains code like the following:

import logo from "../assets/logo.png";

console.log(logo);

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

import { externalAssets } from "rollup-plugin-external-assets";

export default {
	input: "src/index.js",
	output: {
		file: "dist/index.js",
		format: "cjs",
	},
	plugins: [externalAssets("assets/*")],
};

Then call rollup either via the CLI or the API.

Once the bundle is executed, you end up with a dist directory like the following:

dist directory structure

With dist/index.js containing:

"use strict";

var logo = require("./assets/logo-0c6cee7b.png");
console.log(logo);

Options

To tailor the plugin behavior to your needs, you can pass a configuration object as the argument:

include

• Type: string | RegExp | (string | RegExp)[]

A pattern, or array of patterns, to match files the plugin should operate on.

exclude

• Type: string | RegExp | (string | RegExp)[]

A pattern, or array of patterns, to match files the plugin should ignore.

resolve

• Type: string • Default: process.cwd()

The value will be used as the base directory for resolving patterns.

Contributing

Prerequisites

Getting Started

After cloning this repo, ensure dependencies are installed by running:

npm install

Then to build the final bundle:

npm run build

Tests

To run tests:

npm test

To run tests with coverage report:

npm run test:coverage

Coverage report is located in tests/coverage.

Commiting changes

Please follow the conventional commits specification, because semantic-release is used to automate the whole package release workflow including: determining the next version number, generating the release notes and publishing the package.

License

MIT

4.1.1

1 month ago

4.1.0

3 months ago

4.0.1

9 months ago

4.0.0

9 months ago

4.0.2

9 months ago

3.0.1

2 years ago

3.0.0

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

1.1.0

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago