'use strict'; const PRESET_REPLACE_MASTER = [ { from: /\=`https:\/\/vuejs\.org\/errors\/#runtime-\$\{(.+?)\}`/g, to: "=$1" }, { from: /\=`https:\/\/vuejs\.org\/errors{0,1}\-reference\/#runtime-\$\{(.+?)\}`/g, to: "=$1" }, // for scriptlet of apps script { from: /"(\<\?\!{0,1}\={0,1}.+?\?\>)"/g, to: "'$1'" } ]; const vueOnGas = (replaceMaster = PRESET_REPLACE_MASTER) => { return { name: "vue-on-gas", apply: "build", generateBundle(_outputOptions, outputBundle) { console.info(); const chunkNames = Object.keys(outputBundle); chunkNames.forEach((chunkName) => { const chunk = outputBundle[chunkName]; replaceMaster.forEach(({ from, to }) => { const isMatch = typeof from === "string" ? chunk.code.indexOf(from) !== -1 : from.test(chunk.code); if (isMatch) { console.info( `[Vue on GoogleAppsScript plugin] match with pattern: ${from.toString()}` ); chunk.code = chunk.code.replace(from, to); } }); outputBundle[chunkName] = chunk; }); } }; }; exports.PRESET_REPLACE_MASTER = PRESET_REPLACE_MASTER; exports.vueOnGas = vueOnGas;