Switch the markdown preview script to use esbuild

This commit is contained in:
Matt Bierner
2022-03-08 15:47:41 -08:00
parent 79d381f1df
commit 2f48496d2b
4 changed files with 35 additions and 32 deletions

View File

@@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
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];
}
const outDir = path.join(outputRoot, 'media');
esbuild.build({
entryPoints: [
path.join(__dirname, 'preview-src', 'index.ts'),
path.join(__dirname, 'preview-src', 'pre'),
],
bundle: true,
minify: true,
sourcemap: false,
format: 'esm',
outdir: outDir,
platform: 'browser',
target: ['es2020'],
incremental: isWatch,
}).catch(() => process.exit(1));

View File

@@ -424,8 +424,8 @@
"watch": "npm run build-preview && gulp watch-extension:markdown-language-features",
"vscode:prepublish": "npm run build-ext && npm run build-preview",
"build-ext": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:markdown-language-features ./tsconfig.json",
"build-preview": "npx webpack-cli --mode production",
"build-notebook": "node ./esbuild",
"build-notebook": "node ./esbuild-notebook",
"build-preview": "node ./esbuild-preview",
"compile-web": "npx webpack-cli --config extension-browser.webpack.config --mode none",
"watch-web": "npx webpack-cli --config extension-browser.webpack.config --mode none --watch --info-verbosity verbose"
},

View File

@@ -1,30 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
module.exports = {
context: path.resolve(__dirname),
mode: 'production',
entry: {
index: './preview-src/index.ts',
pre: './preview-src/pre.ts',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'media')
}
};