-
-
Save dbowling/954bf470811f718ccc6f7e4e8ffa686a to your computer and use it in GitHub Desktop.
Lit CSS Plugin Snippet for Reboost JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="module" src="./build.js"></script> | |
</head> | |
<body> | |
<my-element></my-element> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LitElement, customElement, css, html } from 'lit-element'; | |
import style from './styles.lit.css'; | |
@customElement('my-element') | |
export class MyElement extends LitElement { | |
static get styles() { | |
return [style]; | |
} | |
render() { | |
return html` | |
<span class="main">Lit Element</span> | |
` | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = () => /** @type import('reboost').ReboostPlugin */ ({ | |
name: 'lit-css-plugin', | |
transformContent({ code, type }) { | |
if (type === 'css') { | |
return { | |
code: ` | |
import { css } from 'lit-element'; | |
const cssString = ${JSON.stringify(code)}; | |
export default css\`${code.replace(/(`|\\|\${)/g, '\\$1')}\`; | |
export { cssString as css } | |
`, | |
type: 'js' | |
} | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { start, builtInPlugins: { UsePlugin } } = require('reboost'); | |
const LitCSSPlugin = require('./lit-css-plugin'); | |
start({ | |
entries: [['./index.js', './build.js']], | |
contentServer: { root: './public' }, | |
plugins: [ | |
UsePlugin({ | |
include: '**/*.lit.css', | |
use: LitCSSPlugin() | |
}) | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.main { | |
font-family: sans-serif; | |
font-size: x-large; | |
background-color: rgb(248, 33, 115); | |
color: white; | |
padding: 10px; | |
display: inline-block; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment