setup.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.uniSetupPlugin = void 0;
  7. const debug_1 = __importDefault(require("debug"));
  8. const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
  9. const debugSetup = (0, debug_1.default)('uni:setup');
  10. function uniSetupPlugin() {
  11. let appVuePath;
  12. let resolvedConfig;
  13. return {
  14. name: 'uni:setup',
  15. configResolved(config) {
  16. resolvedConfig = config;
  17. appVuePath = (0, uni_cli_shared_1.resolveAppVue)(process.env.UNI_INPUT_DIR);
  18. },
  19. transform(code, id) {
  20. const { filename, query } = (0, uni_cli_shared_1.parseVueRequest)(id);
  21. if (filename === appVuePath && !query.vue) {
  22. debugSetup(filename);
  23. return {
  24. code: code +
  25. `;import { setupApp } from '@dcloudio/uni-h5';setupApp(_sfc_main);`,
  26. map: (0, uni_cli_shared_1.withSourcemap)(resolvedConfig)
  27. ? this.getCombinedSourcemap()
  28. : null,
  29. };
  30. }
  31. },
  32. };
  33. }
  34. exports.uniSetupPlugin = uniSetupPlugin;