Created
March 19, 2019 09:09
-
-
Save EdwardIrby/7b98b98a41df7127bd27df6bfa996fe0 to your computer and use it in GitHub Desktop.
@dxworks/rite puppeteer helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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