Last active
August 20, 2019 02:38
-
-
Save longlho/b39473d8e415fc8a1e77b1ddd3a04c33 to your computer and use it in GitHub Desktop.
transformer-p5.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (ts.isImportDeclaration(node)) { | |
// Handle `import foo.css` | |
if (CSS_EXTENSION_REGEX.test(node.moduleSpecifier.getText())) { | |
cssPath = resolveCssPath( | |
node.moduleSpecifier.getText(), | |
sf, | |
tsImportResolver | |
); | |
newNode = importVisitor(cssPath, node); | |
} | |
} else if ( | |
// Handle `require('foo.css')` | |
ts.isCallExpression(node) && | |
node.expression.getText() === "require" && | |
CSS_EXTENSION_REGEX.test(node.arguments[0].getText()) | |
) { | |
cssPath = resolveCssPath( | |
node.arguments[0].getText(), | |
sf, | |
tsImportResolver | |
); | |
try { | |
newNode = generateClassNameObj(cssPath); | |
} catch (e) { | |
console.error(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment