@piotr-cz/rollup-plugin-prepend-modules
v1.0.2
Published
A Rollup plugin which adds import modules to input entry
Downloads
44
Maintainers
Readme
Rollup plugin to prepend modules
A Rollup plugin which adds import modules to input entry
Requirements
This plugin requires an LTS Node version (v14.15.0+) and Rollup v1.20.0+.
Install
Using npm:
npm install @piotr-cz/rollup-plugin-prepend-modules --save-dev
Usage
Create a rollup.config.js
configuration file and import the plugin:
import prependModules from '@piotr-cz/rollup-plugin-prepend-modules';
export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs'
},
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 or the API:
# 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