style.js 849 B

1234567891011121314151617181920
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.transformScopedCss = void 0;
  4. const tags_1 = require("./tags");
  5. const logs_1 = require("../logs");
  6. function transformScopedCss(cssCode) {
  7. checkHtmlTagSelector(cssCode);
  8. return cssCode.replace(/\[(data-v-[a-f0-9]{8})\]/gi, (_, scopedId) => {
  9. return '.' + scopedId;
  10. });
  11. }
  12. exports.transformScopedCss = transformScopedCss;
  13. function checkHtmlTagSelector(cssCode) {
  14. for (const tag in tags_1.HTML_TO_MINI_PROGRAM_TAGS) {
  15. if (new RegExp(`( |\n|\t|,|})${tag}( *)(,|{)`, 'g').test(cssCode)) {
  16. (0, logs_1.output)('warn', `小程序端 style 暂不支持 ${tag} 标签选择器,推荐使用 class 选择器,详情参考:https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#style`);
  17. break;
  18. }
  19. }
  20. }