项目原始demo,不改动
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
Questo repository è archiviato. Puoi vedere i file e clonarli, ma non puoi effettuare richieste di pushj o aprire problemi/richieste di pull.
 
 
 
 

28 righe
810 B

  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.replaceAll = replaceAll;
  6. var matchConstName = /[$#]?[\w-\.]+/g;
  7. function replaceAll(replacements, text) {
  8. var matches = void 0;
  9. while (matches = matchConstName.exec(text)) {
  10. var replacement = replacements[matches[0]];
  11. if (replacement) {
  12. text = text.slice(0, matches.index) + replacement + text.slice(matchConstName.lastIndex);
  13. matchConstName.lastIndex -= matches[0].length - replacement.length;
  14. }
  15. }
  16. return text;
  17. }
  18. exports.default = function (css, translations) {
  19. css.walkDecls(function (decl) {
  20. return decl.value = replaceAll(translations, decl.value);
  21. });
  22. css.walkAtRules('media', function (atRule) {
  23. return atRule.params = replaceAll(translations, atRule.params);
  24. });
  25. };