Skip to content

Instantly share code, notes, and snippets.

@cdock1029
Last active October 21, 2017 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdock1029/a4e5d949e314fcb93e7838791e653d6b to your computer and use it in GitHub Desktop.
Save cdock1029/a4e5d949e314fcb93e7838791e653d6b to your computer and use it in GitHub Desktop.
Example using styled-jsx with preact-cli default template
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))
}
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