Last active
October 21, 2017 20:57
-
-
Save cdock1029/a4e5d949e314fcb93e7838791e653d6b to your computer and use it in GitHub Desktop.
Example using styled-jsx with preact-cli default template
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
export default (config, env, helpers) => { | |
config.node = {process: 'mock'} | |
const {rule} = helpers.getLoadersByName(config, 'babel-loader')[0] | |
rule.options.plugins.splice(3, 0, 'styled-jsx/babel') | |
rule.options.plugins.splice(5, 0, 'styled-jsx/babel') | |
// console.log(JSON.stringify(rule.options.plugins, null, 2)) | |
} |
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 {h, Component} from 'preact' | |
import style from './style' | |
export default class Home extends Component { | |
render() { | |
return ( | |
<div class={style.home}> | |
<h1>Home</h1> | |
<p>This is the Home component.</p> | |
<p className="red">This should be red.</p> | |
<p className="blue">Should be blue.</p> | |
<style jsx>{` | |
.red { | |
color: red; | |
} | |
.blue { | |
color: blue; | |
} | |
`}</style> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment