Skip to content

Instantly share code, notes, and snippets.

@EdwardIrby
Created March 19, 2019 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdwardIrby/7b98b98a41df7127bd27df6bfa996fe0 to your computer and use it in GitHub Desktop.
Save EdwardIrby/7b98b98a41df7127bd27df6bfa996fe0 to your computer and use it in GitHub Desktop.
@dxworks/rite puppeteer helper
/* eslint-disable no-shadow */
import multiEntry from 'rollup-plugin-multi-entry';
import path from 'path';
import resolve from 'rollup-plugin-node-resolve';
const rollup = require('rollup');
export const withBundle = async (...entries) => {
const inputOptions = {
input: entries.length > 1
? entries.map(p => path.resolve(process.cwd(), p))
: path.resolve(process.cwd(), entries[0]),
plugins: [
multiEntry(),
resolve(),
],
};
const outputOptions = {
format: 'iife',
name: '$x',
};
const bundle = await rollup.rollup(inputOptions);
const { output } = await bundle.generate(outputOptions);
const content = `
${output[0].code}
window.$x = $x
`;
return content;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment