25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.0 KiB

  1. const esbuild = require('esbuild');
  2. const path = require('path');
  3. const args = process.argv.slice(2);
  4. let index = args.indexOf('--mode');
  5. const mode = (index >= 0 ? args[index + 1] : undefined) || 'none';
  6. index = args.indexOf('--target');
  7. const target = (index >= 0 ? args[index + 1] : undefined) || 'node';
  8. const watch = args.includes('--watch');
  9. const check = !args.includes('--no-check');
  10. let plugins = [];
  11. let TypeCheckerPlugin;
  12. if (check) {
  13. ({ EsbuildPlugin: TypeCheckerPlugin } = require('vite-esbuild-typescript-checker'));
  14. plugins.push(
  15. TypeCheckerPlugin({
  16. checker: {
  17. async: false,
  18. eslint: {
  19. enabled: true,
  20. files: 'src/**/*.ts',
  21. options: {
  22. // cache: true,
  23. cacheLocation: path.join(
  24. __dirname,
  25. target === 'webworker' ? '.eslintcache.browser' : '.eslintcache',
  26. ),
  27. overrideConfigFile: path.join(
  28. __dirname,
  29. target === 'webworker' ? '.eslintrc.browser.json' : '.eslintrc.json',
  30. ),
  31. },
  32. },
  33. formatter: 'basic',
  34. typescript: {
  35. configFile: target === 'webworker' ? 'tsconfig.browser.json' : 'tsconfig.json',
  36. },
  37. },
  38. }),
  39. );
  40. }
  41. esbuild
  42. .build({
  43. bundle: true,
  44. entryPoints: ['src/extension.ts'],
  45. entryNames: '[dir]/gitlens',
  46. external:
  47. target === 'webworker'
  48. ? ['vscode', 'child_process', 'crypto', 'fs', 'stream', 'os', 'src/env/node/*']
  49. : ['vscode', 'src/env/browser/*'],
  50. format: 'cjs',
  51. keepNames: true,
  52. logLevel: 'info',
  53. mainFields: target === 'webworker' ? ['browser', 'module', 'main'] : ['module', 'main'],
  54. minify: mode === 'production' ? true : false,
  55. outdir: target === 'webworker' ? 'dist/browser' : 'dist',
  56. // outfile: 'dist/gitlens.js',
  57. platform: target === 'webworker' ? 'browser' : target,
  58. sourcemap: true,
  59. // splitting: true,
  60. target: ['es2020', 'chrome91', 'node14.16'],
  61. treeShaking: true,
  62. tsconfig: target === 'webworker' ? 'tsconfig.browser.json' : 'tsconfig.json',
  63. watch: watch,
  64. plugins: plugins,
  65. })
  66. .catch(() => process.exit(1));