Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Last active Jan 1, 2021
Embed
What would you like to do?
Working raw-loader for CSS
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);
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