Build: Simplified theatre:build
This commit is contained in:
parent
7c3095ac5a
commit
3950f34533
2 changed files with 65 additions and 12 deletions
60
theatre/devEnv/utils.ts
Normal file
60
theatre/devEnv/utils.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
import path from 'path'
|
||||
import {build} from 'esbuild'
|
||||
|
||||
export const definedGlobals = {
|
||||
global: 'window',
|
||||
'process.env.version': JSON.stringify(
|
||||
require('../studio/package.json').version,
|
||||
),
|
||||
}
|
||||
|
||||
const a: any = 'hi'
|
||||
|
||||
export function createBundles() {
|
||||
for (const which of ['core', 'studio']) {
|
||||
const pathToPackage = path.join(__dirname, '../', which)
|
||||
const esbuildConfig: Parameters<typeof build>[0] = {
|
||||
entryPoints: [path.join(pathToPackage, 'src/index.ts')],
|
||||
target: ['firefox88', 'chrome90'],
|
||||
loader: {'.png': 'file'},
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
define: definedGlobals,
|
||||
external: ['@theatre/dataverse'],
|
||||
}
|
||||
|
||||
if (which === 'core') {
|
||||
esbuildConfig.platform = 'neutral'
|
||||
esbuildConfig.mainFields = ['browser', 'module', 'main']
|
||||
esbuildConfig.target = ['firefox57', 'chrome58']
|
||||
esbuildConfig.conditions = ['browser', 'node']
|
||||
}
|
||||
|
||||
build({
|
||||
...esbuildConfig,
|
||||
outfile: path.join(pathToPackage, 'dist/index.cjs'),
|
||||
format: 'cjs',
|
||||
})
|
||||
|
||||
build({
|
||||
...esbuildConfig,
|
||||
outfile: path.join(pathToPackage, 'dist/index.mjs'),
|
||||
format: 'esm',
|
||||
})
|
||||
|
||||
build({
|
||||
...esbuildConfig,
|
||||
outfile: path.join(pathToPackage, 'dist/index.min.js'),
|
||||
format: 'iife',
|
||||
external: [],
|
||||
minify: true,
|
||||
globalName: `Theatre.${which}`,
|
||||
legalComments: 'external',
|
||||
platform: 'browser',
|
||||
define: {
|
||||
...definedGlobals,
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue