Skip to content

lmarqs/cypress-rollup-preprocessor

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Cypress Rollup Preprocessor

Build Maintainability Test Coverage

semantic-release

Cypress preprocessor for bundling JavaScript via rollup

Installation

NPM

First install node.js. Then:

npm install cypress-rollup-preprocessor --save-dev

This package relies on the following peer dependencies:

  • rollup

It is likely you already have these installed either directly or as a transient dependency, but if not, you will need to install them.

npm install --save-dev rollup

Compatibility

This version is only compatible with rollup 2.x+

Usage

Check Cypress' official documentation about preprocessors

Cypress >= 10

import { defineConfig } from 'cypress'

import rollupPreprocessor from 'cypress-rollup-preprocessor'

export default defineConfig({
  e2e: {
    setupNodeEvents (on, config) {
      on('file:preprocessor', rollupPreprocessor())
    },
  },
})

Cypress <= 9

const rollupPreprocessor = require("cypress-rollup-preprocessor");

module.exports = (on) => {
  on("file:preprocessor", rollupPreprocessor());
};

Examples

Options

Pass in options as the argument to rollup:

import rollupPreprocessor from 'cypress-rollup-preprocessor'
// Using the options from rollup.config.js
import rollupConfig from '<dir>/rollup.config'

const { output: outputOptions, ...inputOptions } = rollupConfig

// ...
  on('file:preprocessor', rollupPreprocessor({ inputOptions, outputOptions }))
// ...

inputOptions

Object of rollup input options. You can just require in the options from your rollup.config.js to use the same options as your app. Reference: https://rollupjs.org/guide/en/#inputoptions-object

outputOptions

Object of rollup output options. Reference: https://rollupjs.org/guide/en/#outputoptions-object

Contributing

Please read the Contributing guidelines.

Running Tests

To run tests, first install nodeunit and any dependencies via npm:

npm ci

Run tests with:

npm test

Inspiration

Many approaches, patterns and standards were copied from:

Alternatives

License

This project is licensed under the terms of the MIT license.