A simple, no-frills build tool for creating single-file JS bundles for AB test platforms.
- Minifies and bundles code
- Allows ES6 imports
- Continuous "watch" mode
- Supports latest ES6 syntax
- Extensible with es2015+ Babel plugins
- Can handle large experiment code that would otherwise break in Optimizely
Install rollup globally with npm install rollup --global
Install all the package.json
dependencies with: npm install
After installing the packages, run this command in the project directory to start the build:
npm start
Rollup will run and bundle code into the dist
directory. This bundle can be copied and pasted into the Optimizely custom code editor for each variation.
The npm start
command includes a watch for code changes and rebuilds the files, however this can be disabled by removing --watch
from the package.json
start
script.
All the rollup config is located in rollup.config.js
.
Babel plugins can be added to the plugins array. See the list of available ES6 plugins here.
Commonly used utilities are included as its own package here.
The following is a list of plugins this tool uses:
rollup-plugin-babel
- Babel transpilerrollup-plugin-html
- HTML importsrollup-plugin-delete
- Cleans dist folder@rollup/plugin-alias
- Allows@
path aliasrollup-plugin-styles
- SCSS userollup-plugin-banner
- Addsjshint
comments to buildrollup-plugin-commonjs
- CommonJS syntaxrollup-plugin-terser
- Minificationrollup-plugin-node-resolve
- Locates modules w/require