vite/playground/css/main.js

117 lines
3.2 KiB
JavaScript
Raw Normal View History

import './minify.css'
2020-12-22 20:34:02 +00:00
import css from './imported.css'
text('.imported-css', css)
2022-09-30 09:48:53 +00:00
import sugarss from './sugarss.sss'
text('.imported-sugarss', sugarss)
2020-12-22 20:34:02 +00:00
import sass from './sass.scss'
text('.imported-sass', sass)
import less from './less.less'
text('.imported-less', less)
import stylus from './stylus.styl'
text('.imported-stylus', stylus)
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)
2022-04-11 18:13:37 +00:00
import charset from './charset.css'
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 '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')
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 })
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'