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 config = { | |
// Entry point and output | |
entry: './src/index.js', | |
output: { | |
path: process.cwd() + '/dist', | |
filename: 'output.js', | |
}, | |
mode: 'production', | |
}; |
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 = { | |
entry: { /* config */ }, | |
output: { /* config */ }, | |
module: { | |
rules: [ | |
// Regular css files | |
{ |
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 sheet = new CSSStyleSheet(); | |
// Replace all styles synchronously for this style sheet | |
sheet.replaceSync('p { color: green; }'); | |
class FancyComponent1 extends HTMLElement { | |
constructor() { | |
super(); |
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
// Create style node outside of WebComponent | |
const style = document.createElement('style'); | |
style.innerHTML = ` | |
p { color: blue; } | |
`; | |
class FancyComponent extends HTMLElement { | |
constructor() { |
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
class FancyComponent extends HTMLElement { | |
constructor() { | |
super(); | |
const shadowRoot = this.attachShadow({ mode: 'open' }); | |
shadowRoot.innerHTML = ` | |
<!-- Styles are scoped --> | |
<style> |