https://github.com/jlmakes/karma-rollup-preprocessor
Karma preprocessor to bundle ES modules using Rollup.
https://github.com/jlmakes/karma-rollup-preprocessor
karma karma-preprocessor rollup
Last synced: 10 months ago
JSON representation
Karma preprocessor to bundle ES modules using Rollup.
- Host: GitHub
- URL: https://github.com/jlmakes/karma-rollup-preprocessor
- Owner: jlmakes
- License: other
- Created: 2015-12-09T14:47:55.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-17T15:17:30.000Z (almost 3 years ago)
- Last Synced: 2024-05-22T20:46:18.617Z (over 1 year ago)
- Topics: karma, karma-preprocessor, rollup
- Language: JavaScript
- Homepage:
- Size: 385 KB
- Stars: 75
- Watchers: 20
- Forks: 32
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# `karma-rollup-preprocessor`
Karma preprocessor to bundle ES modules using Rollup.
## Installation
```bash
npm install karma-rollup-preprocessor
```
## Configuration
All the options detailed in the [Rollup Documentation](https://github.com/rollup/rollup/wiki/JavaScript-API) can be passed to `rollupPreprocessor`.
### Standard
Below is a well-founded recommendation using the [Bublé](https://buble.surge.sh) ES2015 transpiler:
```js
// karma.conf.js
module.exports = function (config) {
config.set({
files: [
/**
* Make sure to disable Karma’s file watcher
* because the preprocessor will use its own.
*/
{ pattern: 'test/**/*.spec.js', watched: false },
],
preprocessors: {
'test/**/*.spec.js': ['rollup'],
},
rollupPreprocessor: {
/**
* This is just a normal Rollup config object,
* except that `input` is handled for you.
*/
plugins: [require('rollup-plugin-buble')()],
output: {
format: 'iife', // Helps prevent naming collisions.
name: '', // Required for 'iife' format.
sourcemap: 'inline', // Sensible for testing.
},
},
})
}
```
### Configured Preprocessors
Below shows an example where [configured preprocessors](http://karma-runner.github.io/1.0/config/preprocessors.html) can be very helpful:
```js
// karma.conf.js
module.exports = function (config) {
config.set({
files: [{ pattern: 'test/**/*.spec.js', watched: false }],
preprocessors: {
'test/buble/**/*.spec.js': ['rollup'],
'test/babel/**/*.spec.js': ['rollupBabel'],
},
rollupPreprocessor: {
plugins: [require('rollup-plugin-buble')()],
output: {
format: 'iife',
name: '',
sourcemap: 'inline',
},
},
customPreprocessors: {
/**
* Clones the base preprocessor, but overwrites
* its options with those defined below...
*/
rollupBabel: {
base: 'rollup',
options: {
// In this case, to use a different transpiler:
plugins: [require('rollup-plugin-babel')()],
},
},
},
})
}
```
Happy bundling! 