plugin.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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.copyMiniProgramThemeJson = exports.copyMiniProgramPluginJson = void 0;
  7. const fs_1 = __importDefault(require("fs"));
  8. const path_1 = __importDefault(require("path"));
  9. const json_1 = require("../json/json");
  10. const manifest_1 = require("../json/manifest");
  11. exports.copyMiniProgramPluginJson = {
  12. src: ['plugin.json'],
  13. get dest() {
  14. return process.env.UNI_OUTPUT_DIR;
  15. },
  16. transform(source) {
  17. return JSON.stringify((0, json_1.parseJson)(source.toString(), true), null, 2);
  18. },
  19. };
  20. const copyMiniProgramThemeJson = () => {
  21. if (!process.env.UNI_INPUT_DIR)
  22. return [];
  23. const manifestJson = (0, manifest_1.getPlatformManifestJsonOnce)();
  24. const themeLocation = manifestJson.themeLocation || 'theme.json';
  25. const hasThemeJson = fs_1.default.existsSync(path_1.default.resolve(process.env.UNI_INPUT_DIR, themeLocation));
  26. if (hasThemeJson) {
  27. return [
  28. {
  29. src: [(manifestJson.themeLocation = themeLocation)],
  30. get dest() {
  31. return process.env.UNI_OUTPUT_DIR;
  32. },
  33. transform(source) {
  34. return JSON.stringify((0, json_1.parseJson)(source.toString(), true), null, 2);
  35. },
  36. },
  37. ];
  38. }
  39. return [];
  40. };
  41. exports.copyMiniProgramThemeJson = copyMiniProgramThemeJson;