Skip to content

Commit

Permalink
feat: add css codesplit inline test
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Nov 19, 2021
1 parent 4105def commit d1babf7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Expand Up @@ -3,6 +3,7 @@ import { findAssetFile, getColor, isBuild, readManifest } from '../../testUtils'
test('should load both stylesheets', async () => {
expect(await getColor('h1')).toBe('red')
expect(await getColor('h2')).toBe('blue')
expect(await getColor('h3')).toBe('yellow')
})

if (isBuild) {
Expand Down
3 changes: 3 additions & 0 deletions packages/playground/css-codesplit/async.css
@@ -0,0 +1,3 @@
h3 {
color: yellow;
}
8 changes: 7 additions & 1 deletion packages/playground/css-codesplit/main.js
@@ -1,6 +1,12 @@
import './style.css'
import './main.css'
import('./async.css?inline').then((css) => {
const style = document.createElement('style')
style.dataset.import = true
style.textContent = css.default
document.head.appendChild(style)
})

document.getElementById(
'app'
).innerHTML = `<h1>This should be red</h1><h2>This should be blue</h2>`
).innerHTML = `<h1>This should be red</h1><h2>This should be blue</h2><h3>This should be yellow</h3>`

0 comments on commit d1babf7

Please sign in to comment.