Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add style transforms #7

Merged
merged 2 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Let crawler be sync
  • Loading branch information
drwpow committed Mar 18, 2021
commit 3ff65f182a079b7d2c8cc6816ff25e10b7ef1652
1 change: 0 additions & 1 deletion src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import autoprefixer from 'autoprefixer';
import postcss from 'postcss';
import postcssModules from 'postcss-modules';
import sass from 'sass';
import { Style } from './compiler/interfaces';

type StyleType = 'text/css' | 'text/scss' | 'text/sass' | 'text/postcss';

Expand Down
20 changes: 12 additions & 8 deletions src/transform2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,25 @@ async function convertHmxToJsx(template: string, { compileOptions, filename, fil
},
});

let stylesPromises: any[] = [];
walk(ast.css, {
async enter(node) {
enter(node) {
if (node.type !== 'Style') return;

const code = node.content.styles;
const typeAttr = node.attributes && node.attributes.find(({ name }) => name === 'type');
const styles = await transformStyle(code, {
type: (typeAttr.value[0] && typeAttr.value[0].raw) || undefined,
classNames,
filename,
fileID,
}); // TODO: styles needs to go in <head>
console.log({ styles });
stylesPromises.push(
transformStyle(code, {
type: (typeAttr.value[0] && typeAttr.value[0].raw) || undefined,
classNames,
filename,
fileID,
})
); // TODO: styles needs to go in <head>
},
});
const styles = await Promise.all(stylesPromises); // TODO: clean this up
console.log({ styles });

// console.log({
// additionalImports,
Expand Down