Skip to content

Instantly share code, notes, and snippets.

@piotrekwitkowski
Created October 12, 2019 02:02
Show Gist options
  • Save piotrekwitkowski/f02a41185bc4ce1239dfb202709de9db to your computer and use it in GitHub Desktop.
Save piotrekwitkowski/f02a41185bc4ce1239dfb202709de9db to your computer and use it in GitHub Desktop.
Loading scss files in typescript using webpack
import { LitElement, html, customElement, property } from "lit-element";
import style from "./Style";
@customElement('my-component')
class MyComponent extends LitElement {
static styles = style;
render() {
return html`<p>Styled component</p>`;
}
}
declare function require(moduleName: string): any;
import { css } from "lit-element";
const style = require('./styles.scss');
export default css(<any>[style]);
module.exports = async function (_, env) {
return {
resolve: { extensions: [".js", ".ts"] },
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.scss$/,
use: [
{
loader: "css-loader",
// options: { modules: true }
},
{
loader: "sass-loader",
options: {
sassOptions: { includePaths: ['./node_modules'] }
}
},
]
}
]
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment