vite/playground/css/main.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

113 lines
3.2 KiB
JavaScript
Raw Normal View History

import './minify.css'
import './imported.css'
import './sugarss.sss'
import './sass.scss'
import './less.less'
import './stylus.styl'
import css from './imported-inline.css?inline'
2020-12-22 20:34:02 +00:00
text('.imported-css', css)
import rawCss from './raw-imported.css?raw'
text('.raw-imported-css', rawCss)
2020-12-22 20:34:02 +00:00
import mod from './mod.module.css'
document.querySelector('.modules').classList.add(mod['apply-color'])
2020-12-22 20:34:02 +00:00
text('.modules-code', JSON.stringify(mod, null, 2))
import sassMod from './mod.module.scss'
document.querySelector('.modules-sass').classList.add(sassMod['apply-color'])
2020-12-22 20:34:02 +00:00
text('.modules-sass-code', JSON.stringify(sassMod, null, 2))
import composesPathResolvingMod from './composes-path-resolving.module.css'
document
.querySelector('.path-resolved-modules-css')
.classList.add(...composesPathResolvingMod['path-resolving-css'].split(' '))
document
.querySelector('.path-resolved-modules-sass')
.classList.add(...composesPathResolvingMod['path-resolving-sass'].split(' '))
document
.querySelector('.path-resolved-modules-less')
.classList.add(...composesPathResolvingMod['path-resolving-less'].split(' '))
text(
'.path-resolved-modules-code',
JSON.stringify(composesPathResolvingMod, null, 2),
)
import inlineMod from './inline.module.css?inline'
text('.modules-inline', inlineMod)
import charset from './charset.css?inline'
2022-04-11 18:13:37 +00:00
text('.charset-css', charset)
import './layered/index.css'
import './dep.css'
import './glob-dep.css'
2022-08-01 05:39:26 +00:00
// eslint-disable-next-line import/order
2022-07-01 03:17:19 +00:00
import { barModuleClasses } from '@vitejs/test-css-js-dep'
document
.querySelector('.css-js-dep-module')
.classList.add(barModuleClasses.cssJsDepModule)
2020-12-22 20:34:02 +00:00
function text(el, text) {
document.querySelector(el).textContent = text
}
if (import.meta.hot) {
import.meta.hot.accept('./mod.module.css', (newMod) => {
const list = document.querySelector('.modules').classList
list.remove(mod.applyColor)
list.add(newMod.applyColor)
text('.modules-code', JSON.stringify(newMod.default, null, 2))
})
import.meta.hot.accept('./mod.module.scss', (newMod) => {
const list = document.querySelector('.modules-sass').classList
list.remove(mod.applyColor)
list.add(newMod.applyColor)
text('.modules-sass-code', JSON.stringify(newMod.default, null, 2))
})
}
2020-12-30 23:47:35 +00:00
// async
import('./async')
if (import.meta.env.DEV) {
import('./async-treeshaken')
}
// inlined
import inlined from './inlined.css?inline'
text('.inlined-code', inlined)
// glob
const glob = import.meta.glob('./glob-import/*.css', { query: '?inline' })
Promise.all(
Object.keys(glob).map((key) => glob[key]().then((i) => i.default)),
).then((res) => {
text('.imported-css-glob', JSON.stringify(res, null, 2))
})
// globEager
const globEager = import.meta.glob('./glob-import/*.css', {
eager: true,
query: '?inline',
})
text('.imported-css-globEager', JSON.stringify(globEager, null, 2))
import postcssSourceInput from './postcss-source-input.css?query=foo'
text('.postcss-source-input', postcssSourceInput)
2022-07-01 03:08:47 +00:00
import aliasContent from '#alias'
text('.aliased-content', aliasContent)
import aliasModule from '#alias-module'
document
.querySelector('.aliased-module')
.classList.add(aliasModule.aliasedModule)
import './unsupported.css'
import './async/index'