Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CSS modules namespace import
// 249 bytes
var o={helloWorld:"hello-world-123",fooBar:"foo-bar-245",barBaz:"bar-baz-934"};let l=Object.assign(document.createElement("div"),{textContent:"Hello world!",className:[o.helloWorld,o.helloWorld,o.fooBar,o.barBaz].join(" ")});document.body.append(l);
// 178 bytes
let e="hello-world-123",o=Object.assign(document.createElement("div"),{textContent:"Hello world!",className:[e,e,"foo-bar-245","bar-baz-934"].join(" ")});document.body.append(o);
// style.module.css
export default {
helloWorld: 'hello-world-123',
fooBar: 'foo-bar-245',
barBaz: 'bar-baz-934',
};
// index.js
import css from './style.module.css';
let el = Object.assign(document.createElement('div'), {
textContent: 'Hello world!',
className: [css.helloWorld, css.helloWorld, css.fooBar, css.barBaz].join(' '),
});
document.body.append(el);
// style.module.css
export let helloWorld = 'hello-world-123';
export let fooBar = 'foo-bar-245';
export let barBaz = 'bar-baz-934';
// index.js
import * as css from './style.module.css';
let el = Object.assign(document.createElement('div'), {
textContent: 'Hello world!',
className: [css.helloWorld, css.helloWorld, css.fooBar, css.barBaz].join(' '),
});
document.body.append(el);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment