diff --git a/src/output/moduleCompiler.ts b/src/output/moduleCompiler.ts index 2740fd67..6c5a2a66 100644 --- a/src/output/moduleCompiler.ts +++ b/src/output/moduleCompiler.ts @@ -167,9 +167,12 @@ function processModule(store: Store, src: string, filename: string) { // import * as ok from 'foo' --> ok -> __import_foo__ if (node.type === 'ImportDeclaration') { const source = node.source.value - // import 'foo/style.css' --> , href is import.meta.resolve('foo/style.css') - // import 'http://127.0.0.1/style.css' --> - if (source.endsWith('.css')) { + if (source.endsWith('?raw')) { + const url = source.slice(0, -4) + s.overwrite(node.start!, node.end!, `const ${node.specifiers[0].local.name} = await (await fetch(${url.startsWith('http') ? `'${url}'` : `import.meta.resolve('${url}')`})).text()`) + } else if (source.endsWith('.css')) { + // import 'foo/style.css' --> , href is import.meta.resolve('foo/style.css') + // import 'http://127.0.0.1/style.css' --> s.overwrite(node.start!, node.end!, `if(true){ const link = document.createElement('link'); link.rel = 'stylesheet';