Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ImportDeclaration(p) {
const {source, specifiers} = p.node;
if (cssFileRe && cssFileRe.test(source.value)) {
const file = utils.resolveDependency({
filename: source.value,
basedir: path.dirname(filename),
});
const code = fs
.readFileSync(file)
.toString()
// escape backticks and backslashes
.replace(/[`\\]/g, '\\$&');
const append = t.taggedTemplateExpression(
t.identifier(addImport('css')),
t.templateLiteral(
[
t.templateElement({
raw: code,
ImportDeclaration(p) {
const {source, specifiers} = p.node;
if (cssFileRe && cssFileRe.test(source.value)) {
const file = utils.resolveDependency({
filename: source.value,
basedir: path.dirname(filename),
});
const code = fs.readFileSync(file).toString();
const append = t.taggedTemplateExpression(
t.identifier(addImport('css')),
t.templateLiteral(
[
t.templateElement({
raw: code,
cooked: code,
}),
],
[],
.replace(/\/\*__reshadow-styles__:"(.*?)"\*\//, (match, dep) => {
const depPath = utils.resolveDependency({
filename: dep,
basedir: path.dirname(filepath),
});
this.dependency(depPath);
return '';
});