mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:51:57 +00:00
* move bext-only extension host worker to client/browser * use esbuild for browser extension build esbuild is much faster and simpler than Webpack.
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import type * as esbuild from 'esbuild'
|
|
import shelljs from 'shelljs'
|
|
import signale from 'signale'
|
|
|
|
import { buildNpm } from './build-npm'
|
|
import * as tasks from './tasks'
|
|
|
|
export const copyAssetsPlugin: esbuild.Plugin = {
|
|
name: 'copyAssets',
|
|
setup: (): void => {
|
|
tasks.copyAssets()
|
|
},
|
|
}
|
|
|
|
export function browserBuildStepsPlugin(mode: 'dev' | 'prod'): esbuild.Plugin {
|
|
return {
|
|
name: 'browserBuildSteps',
|
|
setup: (build: esbuild.PluginBuild): void => {
|
|
build.onEnd(async result => {
|
|
if (result.errors.length === 0) {
|
|
signale.info('Running browser build steps...')
|
|
tasks.buildChrome(mode)()
|
|
tasks.buildFirefox(mode)()
|
|
tasks.buildEdge(mode)()
|
|
if (mode === 'prod') {
|
|
if (isXcodeAvailable()) {
|
|
tasks.buildSafari(mode)()
|
|
} else {
|
|
signale.debug(
|
|
'Skipping Safari build because Xcode tools were not found (xcrun, xcodebuild)'
|
|
)
|
|
}
|
|
}
|
|
tasks.copyIntegrationAssets()
|
|
if (mode === 'prod') {
|
|
await buildNpm()
|
|
}
|
|
}
|
|
})
|
|
},
|
|
}
|
|
}
|
|
|
|
function isXcodeAvailable(): boolean {
|
|
return !!shelljs.which('xcrun') && !!shelljs.which('xcodebuild')
|
|
}
|