2021-11-10 15:35:51 +00:00
|
|
|
|
/* eslint-disable */
|
|
|
|
|
const fs = require('fs')
|
2022-09-01 08:49:01 +00:00
|
|
|
|
const pkg = require('../package.json')
|
2021-11-10 15:35:51 +00:00
|
|
|
|
const esbuild = require('esbuild')
|
2022-09-01 08:49:01 +00:00
|
|
|
|
const { exec } = require('child_process')
|
2021-11-10 15:35:51 +00:00
|
|
|
|
|
2021-12-22 00:14:38 +00:00
|
|
|
|
const { log: jslog } = console
|
|
|
|
|
|
2022-09-01 08:49:01 +00:00
|
|
|
|
async function copyEditor() {
|
|
|
|
|
if (fs.existsSync('./editor')) {
|
|
|
|
|
fs.rmSync('./editor', { recursive: true }, (e) => {
|
|
|
|
|
if (e) {
|
|
|
|
|
throw e
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
exec(`cp -r ../editor/dist editor;`, (error, stdout, stderr) => {
|
|
|
|
|
if (error) {
|
|
|
|
|
throw new Error(error.message)
|
|
|
|
|
}
|
|
|
|
|
if (stderr && stderr.search('warning') !== 0) {
|
|
|
|
|
throw new Error(stderr)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} catch (e) {
|
|
|
|
|
jslog(`× ${pkg.name}: Build failed due to an error.`)
|
|
|
|
|
jslog(e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 15:35:51 +00:00
|
|
|
|
async function main() {
|
2022-09-01 08:49:01 +00:00
|
|
|
|
await copyEditor()
|
|
|
|
|
|
2021-11-10 15:35:51 +00:00
|
|
|
|
if (fs.existsSync('./dist')) {
|
|
|
|
|
fs.rmSync('./dist', { recursive: true }, (e) => {
|
|
|
|
|
if (e) {
|
|
|
|
|
throw e
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2021-11-13 08:49:34 +00:00
|
|
|
|
esbuild.buildSync({
|
2021-11-10 15:35:51 +00:00
|
|
|
|
entryPoints: ['./src/extension.ts'],
|
|
|
|
|
outdir: 'dist/web',
|
2021-11-13 11:02:10 +00:00
|
|
|
|
minify: false,
|
2021-11-10 15:35:51 +00:00
|
|
|
|
bundle: true,
|
|
|
|
|
format: 'cjs',
|
|
|
|
|
target: 'es6',
|
2022-05-11 15:58:40 +00:00
|
|
|
|
platform: 'node',
|
2021-11-10 15:35:51 +00:00
|
|
|
|
define: {
|
|
|
|
|
'process.env.NODE_ENV': '"production"',
|
|
|
|
|
},
|
|
|
|
|
tsconfig: './tsconfig.json',
|
2021-11-13 08:49:34 +00:00
|
|
|
|
external: ['vscode'],
|
2021-11-10 15:35:51 +00:00
|
|
|
|
})
|
2021-12-22 00:14:38 +00:00
|
|
|
|
jslog(`Built package.`)
|
2021-11-10 15:35:51 +00:00
|
|
|
|
} catch (e) {
|
2021-12-22 00:14:38 +00:00
|
|
|
|
jslog(`× Build failed due to an error.`)
|
|
|
|
|
jslog(e)
|
2021-11-10 15:35:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main()
|