Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rollup-plugin-external-assets

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-external-assets

A rollup plugin to make assets external but include them in the output.

  • 4.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

  • nodejs
  • npm

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

Keywords

FAQs

Package last updated on 13 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc