Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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
You can’t perform that action at this time.