Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/piotr-cz/rollup-plugin-prepend-modules
A Rollup plugin which adds import modules to input entry
https://github.com/piotr-cz/rollup-plugin-prepend-modules
modules rollup-plugin
Last synced: 27 days ago
JSON representation
A Rollup plugin which adds import modules to input entry
- Host: GitHub
- URL: https://github.com/piotr-cz/rollup-plugin-prepend-modules
- Owner: piotr-cz
- License: mit
- Created: 2020-11-20T09:35:06.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-03T08:08:21.000Z (2 months ago)
- Last Synced: 2024-10-09T09:36:58.451Z (30 days ago)
- Topics: modules, rollup-plugin
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[npm]: https://img.shields.io/npm/v/@piotr-cz/rollup-plugin-prepend-modules
[npm-url]: https://www.npmjs.com/package/@piotr-cz/rollup-plugin-prepend-modules[![npm][npm]][npm-url]
# Rollup plugin to prepend modules
A Rollup plugin which adds import modules to input entry
## Requirements
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.15.0+) and Rollup v1.20.0+.
## Install
Using npm:
```console
npm install @piotr-cz/rollup-plugin-prepend-modules --save-dev
```## Usage
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
```js
import prependModules from '@piotr-cz/rollup-plugin-prepend-modules';export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'esm'
},
plugins: [
// Use plugin only in development environment
process.env.NODE_ENV === 'development' && prependModules({
modules: ['preact/debug'],
sourceMap: true
})
]
};
```Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api):
```console
# Optionally set environment to development
npx rollup --config --environment NODE_ENV:development
```The configuration above will add `import 'preact/debug';` to input entry (`src/index.js` in this case).
## Options
### `modules`
type: `string[]`
default: `[]`An array of modules to prepend
### `sourceMap`
type: `boolean`
default: `true`If false, skips source map generation
## Meta
[LICENSE (MIT)](/LICENSE)