diff options
author | 2021-03-18 18:10:08 -0600 | |
---|---|---|
committer | 2021-03-18 18:10:08 -0600 | |
commit | d75107a20e971ad26a0398229b2b3fd13c45c6ee (patch) | |
tree | 850ae9112a20916501e98324b57510ed8785c315 /src/optimize/styles.ts | |
parent | d27bd74b055b23a6eb455969755b3ee7f687fd61 (diff) | |
download | astro-d75107a20e971ad26a0398229b2b3fd13c45c6ee.tar.gz astro-d75107a20e971ad26a0398229b2b3fd13c45c6ee.tar.zst astro-d75107a20e971ad26a0398229b2b3fd13c45c6ee.zip |
Respect comments when scanning imports
Use es-module-lexer for import scanning in HMX scripts
Diffstat (limited to 'src/optimize/styles.ts')
-rw-r--r-- | src/optimize/styles.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/optimize/styles.ts b/src/optimize/styles.ts index b654ca7d1..6d15cb602 100644 --- a/src/optimize/styles.ts +++ b/src/optimize/styles.ts @@ -1,8 +1,8 @@ import type { Ast, TemplateNode } from '../compiler/interfaces'; -import type { Optimizer } from './types' +import type { Optimizer } from './types'; import { transformStyle } from '../style.js'; -export default function({ filename, fileID }: { filename: string, fileID: string }): Optimizer { +export default function ({ filename, fileID }: { filename: string; fileID: string }): Optimizer { const classNames: Set<string> = new Set(); let stylesPromises: any[] = []; @@ -11,20 +11,20 @@ export default function({ filename, fileID }: { filename: string, fileID: string html: { Element: { enter(node) { - for(let attr of node.attributes) { - if(attr.name === 'class') { - for(let value of attr.value) { - if(value.type === 'Text') { + for (let attr of node.attributes) { + if (attr.name === 'class') { + for (let value of attr.value) { + if (value.type === 'Text') { const classes = value.data.split(' '); - for(const className in classes) { + for (const className in classes) { classNames.add(className); } } } } } - } - } + }, + }, }, css: { Style: { @@ -39,13 +39,13 @@ export default function({ filename, fileID }: { filename: string, fileID: string fileID, }) ); // TODO: styles needs to go in <head> - } - } - } + }, + }, + }, }, async finalize() { const styles = await Promise.all(stylesPromises); // TODO: clean this up - console.log({ styles }); - } + // console.log({ styles }); + }, }; -}
\ No newline at end of file +} |