2022-03-09 08:23:14 +08:00
|
|
|
/*---------------------------------------------------------------------------------------------
|
|
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
|
|
*--------------------------------------------------------------------------------------------*/
|
2022-03-25 05:13:18 +08:00
|
|
|
// @ts-check
|
2022-03-09 08:23:14 +08:00
|
|
|
const path = require('path');
|
|
|
|
const esbuild = require('esbuild');
|
|
|
|
|
|
|
|
const args = process.argv.slice(2);
|
|
|
|
|
|
|
|
const isWatch = args.indexOf('--watch') >= 0;
|
|
|
|
|
|
|
|
let outputRoot = __dirname;
|
|
|
|
const outputRootIndex = args.indexOf('--outputRoot');
|
|
|
|
if (outputRootIndex >= 0) {
|
|
|
|
outputRoot = args[outputRootIndex + 1];
|
|
|
|
}
|
|
|
|
|
2022-03-25 05:13:18 +08:00
|
|
|
const srcDir = path.join(__dirname, 'preview-src');
|
2022-03-09 08:23:14 +08:00
|
|
|
const outDir = path.join(outputRoot, 'media');
|
|
|
|
|
2022-03-25 05:13:18 +08:00
|
|
|
async function build() {
|
|
|
|
await esbuild.build({
|
2023-03-08 11:46:53 +08:00
|
|
|
entryPoints: {
|
|
|
|
'index': path.join(srcDir, 'index.ts'),
|
|
|
|
'codicon': path.join(__dirname, 'node_modules', 'vscode-codicons', 'dist', 'codicon.css'),
|
|
|
|
},
|
|
|
|
loader: {
|
|
|
|
'.ttf': 'dataurl',
|
|
|
|
},
|
2022-03-25 05:13:18 +08:00
|
|
|
bundle: true,
|
|
|
|
minify: true,
|
|
|
|
sourcemap: false,
|
|
|
|
format: 'esm',
|
|
|
|
outdir: outDir,
|
|
|
|
platform: 'browser',
|
|
|
|
target: ['es2020'],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
build().catch(() => process.exit(1));
|
|
|
|
|
|
|
|
if (isWatch) {
|
|
|
|
const watcher = require('@parcel/watcher');
|
|
|
|
watcher.subscribe(srcDir, () => {
|
|
|
|
return build();
|
|
|
|
});
|
|
|
|
}
|