serverPluginAssets.js 523 B

123456789101112131415
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.assetPathPlugin = void 0;
  4. const utils_1 = require("../utils");
  5. exports.assetPathPlugin = ({ app, resolver }) => {
  6. app.use(async (ctx, next) => {
  7. if (resolver.isAssetRequest(ctx.path) && utils_1.isImportRequest(ctx)) {
  8. ctx.type = 'js';
  9. ctx.body = `export default ${JSON.stringify(ctx.path)}`;
  10. return;
  11. }
  12. return next();
  13. });
  14. };
  15. //# sourceMappingURL=serverPluginAssets.js.map