Created
October 12, 2019 02:02
-
-
Save piotrekwitkowski/f02a41185bc4ce1239dfb202709de9db to your computer and use it in GitHub Desktop.
Loading scss files in typescript using webpack
This file contains hidden or 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, 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>`; | |
} | |
} |
This file contains hidden or 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
declare function require(moduleName: string): any; | |
import { css } from "lit-element"; | |
const style = require('./styles.scss'); | |
export default css(<any>[style]); |
This file contains hidden or 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 = 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