index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.uniUVuePlugin = void 0;
  4. const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
  5. const define_1 = require("../../config/define");
  6. const resolve_1 = require("../../config/resolve");
  7. const css_1 = require("../../config/css");
  8. const configResolved_1 = require("../../configResolved");
  9. function uniUVuePlugin(options) {
  10. return {
  11. name: 'uni:uvue',
  12. config(config, env) {
  13. options.command = env.command;
  14. let base = config.base;
  15. if (!base) {
  16. const { h5 } = (0, uni_cli_shared_1.parseManifestJsonOnce)(options.inputDir);
  17. base = (h5 && h5.router && h5.router.base) || '';
  18. }
  19. if (!base) {
  20. base = '/';
  21. }
  22. options.base = base;
  23. return {
  24. base: process.env.UNI_H5_BASE || base,
  25. root: process.env.VITE_ROOT_DIR,
  26. // TODO 临时设置为__static__,屏蔽警告:https://github.com/vitejs/vite/blob/824d042535033a5c3d7006978c0d05c201cd1c25/packages/vite/src/node/server/middlewares/transform.ts#L125
  27. publicDir: config.publicDir || '__static__',
  28. define: (0, define_1.createDefine)(options),
  29. resolve: (0, resolve_1.createResolve)(options, config),
  30. logLevel: config.logLevel || 'warn',
  31. optimizeDeps: {
  32. disabled: true,
  33. },
  34. css: (0, css_1.createCss)(options, config),
  35. };
  36. },
  37. configResolved(config) {
  38. (0, configResolved_1.initLogger)(config);
  39. },
  40. };
  41. }
  42. exports.uniUVuePlugin = uniUVuePlugin;