(file, displayLog = true)
| 115 | |
| 116 | /** build as iife, every file will be bundled separately */ |
| 117 | export async function buildIifeFile(file, displayLog = true) { |
| 118 | // for `slick.core.js` file only, we'll add it to the global Slick variable |
| 119 | const globalName = /slick.core.[jt]s/gi.test(file) ? 'Slick' : undefined; |
| 120 | const startTime = new Date().getTime(); |
| 121 | await runBuild({ |
| 122 | entryPoints: [file], |
| 123 | format: 'iife', |
| 124 | globalName, |
| 125 | define: { IIFE_ONLY: 'true' }, |
| 126 | outfile: `dist/browser/${file.replace('src', '').replace(/.[j|t]s/, '')}.js`, |
| 127 | plugins: [ |
| 128 | removeImportsPlugin, |
| 129 | ], |
| 130 | }); |
| 131 | |
| 132 | if (displayLog) { |
| 133 | const endTime = new Date().getTime(); |
| 134 | console.log(`[${styleText('yellow', 'esbuild ⚡')}] Built "${file}" to "iife" format in ${endTime - startTime}ms`); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Run esbuild build with default configs, merge any options provided |
no test coverage detected