build.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. //@ts-check
  6. const esbuild = require('esbuild');
  7. const path = require('path');
  8. const { removeDir } = require('../../build/fs');
  9. removeDir('samples/browser-esm-esbuild/dist', (entry) => /index.html$/.test(entry));
  10. const workerEntryPoints = [
  11. 'vs/language/json/json.worker.js',
  12. 'vs/language/css/css.worker.js',
  13. 'vs/language/html/html.worker.js',
  14. 'vs/language/typescript/ts.worker.js',
  15. 'vs/editor/editor.worker.js'
  16. ];
  17. build({
  18. entryPoints: workerEntryPoints.map((entry) => `../node_modules/monaco-editor/esm/${entry}`),
  19. bundle: true,
  20. format: 'iife',
  21. outbase: '../node_modules/monaco-editor/esm/',
  22. outdir: path.join(__dirname, 'dist')
  23. });
  24. build({
  25. entryPoints: ['index.js'],
  26. bundle: true,
  27. format: 'iife',
  28. outdir: path.join(__dirname, 'dist'),
  29. loader: {
  30. '.ttf': 'file'
  31. }
  32. });
  33. /**
  34. * @param {import ('esbuild').BuildOptions} opts
  35. */
  36. function build(opts) {
  37. esbuild.build(opts).then((result) => {
  38. if (result.errors.length > 0) {
  39. console.error(result.errors);
  40. }
  41. if (result.warnings.length > 0) {
  42. console.error(result.warnings);
  43. }
  44. });
  45. }