build.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. "use strict";
  2. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  3. if (k2 === undefined) k2 = k;
  4. var desc = Object.getOwnPropertyDescriptor(m, k);
  5. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  6. desc = { enumerable: true, get: function() { return m[k]; } };
  7. }
  8. Object.defineProperty(o, k2, desc);
  9. }) : (function(o, m, k, k2) {
  10. if (k2 === undefined) k2 = k;
  11. o[k2] = m[k];
  12. }));
  13. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  14. Object.defineProperty(o, "default", { enumerable: true, value: v });
  15. }) : function(o, v) {
  16. o["default"] = v;
  17. });
  18. var __importStar = (this && this.__importStar) || function (mod) {
  19. if (mod && mod.__esModule) return mod;
  20. var result = {};
  21. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  22. __setModuleDefault(result, mod);
  23. return result;
  24. };
  25. Object.defineProperty(exports, "__esModule", { value: true });
  26. exports.VueViteBuildCLI = exports.VueViteBuildRunner = void 0;
  27. const build_1 = require("../../build");
  28. class VueViteBuildRunner extends build_1.BuildRunner {
  29. constructor(e) {
  30. super();
  31. this.e = e;
  32. }
  33. async getCommandMetadata() {
  34. return {};
  35. }
  36. createOptionsFromCommandLine(inputs, options) {
  37. const baseOptions = super.createBaseOptionsFromCommandLine(inputs, options);
  38. return {
  39. ...baseOptions,
  40. type: 'vue',
  41. };
  42. }
  43. async buildProject(options) {
  44. const vueScripts = new VueViteBuildCLI(this.e);
  45. await vueScripts.build(options);
  46. }
  47. }
  48. exports.VueViteBuildRunner = VueViteBuildRunner;
  49. class VueViteBuildCLI extends build_1.BuildCLI {
  50. constructor() {
  51. super(...arguments);
  52. this.name = 'Vite CLI Service';
  53. this.pkg = 'vite';
  54. this.program = 'vite';
  55. this.prefix = 'vite';
  56. this.script = build_1.BUILD_SCRIPT;
  57. }
  58. async buildArgs(options) {
  59. const { pkgManagerArgs } = await Promise.resolve().then(() => __importStar(require('../../utils/npm')));
  60. if (this.resolvedProgram === this.program) {
  61. return ['build', ...(options['--'] || [])];
  62. }
  63. else {
  64. const [, ...pkgArgs] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'run', script: this.script, scriptArgs: options['--'] });
  65. return pkgArgs;
  66. }
  67. }
  68. async buildEnvVars(options) {
  69. const env = {};
  70. return { ...await super.buildEnvVars(options), ...env };
  71. }
  72. }
  73. exports.VueViteBuildCLI = VueViteBuildCLI;