2021-08-07 23:24:37 +02:00
|
|
|
import * as path from 'path'
|
2021-06-28 16:37:02 +02:00
|
|
|
import {build} from 'esbuild'
|
|
|
|
|
|
|
|
const definedGlobals = {
|
|
|
|
global: 'window',
|
|
|
|
}
|
|
|
|
|
|
|
|
function createBundles(watch: boolean) {
|
|
|
|
const pathToPackage = path.join(__dirname, '../')
|
|
|
|
const esbuildConfig: Parameters<typeof build>[0] = {
|
|
|
|
entryPoints: [path.join(pathToPackage, 'src/index.ts')],
|
|
|
|
bundle: true,
|
|
|
|
sourcemap: true,
|
|
|
|
define: definedGlobals,
|
|
|
|
watch,
|
|
|
|
platform: 'neutral',
|
|
|
|
mainFields: ['browser', 'module', 'main'],
|
|
|
|
target: ['firefox57', 'chrome58'],
|
|
|
|
conditions: ['browser', 'node'],
|
|
|
|
}
|
|
|
|
|
|
|
|
build({
|
|
|
|
...esbuildConfig,
|
2021-08-07 23:24:37 +02:00
|
|
|
outfile: path.join(pathToPackage, 'dist/index.js'),
|
2021-06-28 16:37:02 +02:00
|
|
|
format: 'cjs',
|
|
|
|
})
|
|
|
|
|
2021-08-07 23:24:37 +02:00
|
|
|
// build({
|
|
|
|
// ...esbuildConfig,
|
|
|
|
// outfile: path.join(pathToPackage, 'dist/index.mjs'),
|
|
|
|
// format: 'esm',
|
|
|
|
// })
|
2021-06-28 16:37:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
createBundles(false)
|