Last active
January 1, 2021 22:01
-
-
Save YonatanKra/0d67626f3efcfe81072d81d67133d822 to your computer and use it in GitHub Desktop.
Working raw-loader for CSS
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 style from "./app.element.css"; | |
import template from "./app.element.html"; | |
export class AppElement extends HTMLElement { | |
public static observedAttributes = []; | |
connectedCallback() { | |
const title = 'custom-webpack'; | |
this.attachShadow({mode: 'open'}); | |
this.shadowRoot.innerHTML = `<style>${style}</style>` + template.replace('${title}', title); | |
} | |
} | |
customElements.define('custom-webpack-root', AppElement); |
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 = (config, context) => { | |
return { | |
...config, | |
module: { | |
...config.module, | |
rules: [ | |
config.module.rules[0], | |
{ | |
test: /\.html$/i, | |
use: 'raw-loader', | |
}, | |
{ | |
test: /\.css$/i, | |
use: 'raw-loader', | |
}, | |
], | |
}, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment