Skip to content

Commit

Permalink
fix: remove updating classe utils
Browse files Browse the repository at this point in the history
1. add debug logs
2. update tailwind-mappings
  • Loading branch information
rajasegar committed Jun 8, 2021
1 parent aeeb4b0 commit d5a6c00
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
"dependencies": {
"chalk": "^4.1.1",
"codemod-cli": "^3.1.2",
"debug": "^4.3.1",
"ember-template-recast": "^5.0.3",
"globby": "^11.0.3",
"minimist": "^1.2.5",
"ora": "^5.4.0",
"parsel-js": "^1.0.2",
"postcss": "^8.2.15",
"tailwind-mappings": "^1.5.5",
"tailwind-mappings": "^1.5.6",
"workerpool": "^6.1.4"
},
"devDependencies": {
Expand Down
10 changes: 6 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion transforms/tailwind/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { getOptions: getCLIOptions } = require('codemod-cli');
const fs = require('fs');
const transform = require('./transform');
const debug = require('debug')('etc');

const postcss = require('postcss');
const parsel = require('parsel-js');
Expand Down Expand Up @@ -103,8 +104,34 @@ module.exports = function (file, parser, opts) {
});
});

// Copy class utils from compounds
Object.keys(tailwindMappings.compounds)
.filter((compound) => compound.startsWith('.'))
.forEach((className) => {
let classObj = tailwindMappings.classes[className];
if (classObj) {
classObj += ' ' + tailwindMappings.compounds[className];
tailwindMappings.classes[className] = classObj;
} else {
tailwindMappings.classes[className] = tailwindMappings.compounds[className];
}
});

// Copy element utils from compounds
Object.keys(tailwindMappings.compounds)
.filter((compound) => !compound.startsWith('.'))
.forEach((element) => {
let elementUtil = tailwindMappings.elements[element];
if (elementUtil) {
elementUtil += ' ' + tailwindMappings.compounds[element];
tailwindMappings.elements[element] = elementUtil;
} else {
tailwindMappings.elements[element] = tailwindMappings.compounds[element];
}
});

try {
//console.log(tailwindMappings);
debug('Final Tailwind mappings:\n ', tailwindMappings);
return transform(file, tailwindMappings);
} catch (e) {
throw new Error(
Expand Down

0 comments on commit d5a6c00

Please sign in to comment.