import resolve from 'rollup-plugin-node-resolve'; import { terser } from 'rollup-plugin-terser'; import { promisify } from 'util'; import { exec } from 'child_process'; const __exec = promisify(exec); const PRODUCTION = !!process.env.PRODUCTION; const OUTFILE_DEV = `build/bundle.js`; const OUTFILE_PROD = `build/b${ Date.now() }.min.js`; (async () => { if (! PRODUCTION) { return ; } const outDev = OUTFILE_DEV .replace(/\//g, '\\/'); const outProd = OUTFILE_PROD.replace(/\//g, '\\/'); const sed = process.platform === 'darwin' ? `sed -i ''` : `sed -i''` ; console.log( await __exec(`${sed} "s/${ outDev }/${ outProd }/g" views/layout.hbs`) ); })(); export default { input: `dist/controller.js`, output: { file: PRODUCTION ? OUTFILE_PROD : OUTFILE_DEV , format: `iife`, }, plugins: [ resolve(), PRODUCTION ? terser() : undefined, ] }