Just import this in your app's index/entry module, before any imports that would bring in preact-material-components.
| export const h=(t,p,...c)=>({t,p,c,k:p&&p.key}) | |
| export const render=(e,d,t=d.t||(d.t={}),p,r,c,m,y)=> | |
| // arrays | |
| e.map?e.map((e,p)=>render(e,d,t.o&&t.o[p])): | |
| // components | |
| e.t.call?(e.i=render((render.c=e).t(Object.assign({children:e.c},e.p),e.s=t.s||{},t=> | |
| render(Object.assign(e.s,t)&&e,d,e)),t.i||d,t&&t.i||{}),d.t=t=e):( | |
| // create notes | |
| m=t.d||(e.t?document.createElement(e.t):new Text(e.p)), | |
| // diff props |
| import { h, hydrate, Component } from 'preact'; | |
| function interopDefault(mod) { | |
| return mod && mod.default || mod; | |
| } | |
| export function ServerHydrator({ load, ...props }) { | |
| const Child = interopDefault(load()); | |
| return ( | |
| <section> |
This loader optimizes the output of mini-css-extract-plugin and/or css-loader,
entirely removing the potentially large CSS classname mappings normally inlined into your bundle when using CSS Modules.
Run npm install constant-locals-loader, then make these changes in your Webpack config:
module.exports = {
module: {This shows how to use styled-components with preact-cli.
Styles are collected and inlined during pre-rendering, with no extra build or configuration step required.
The only configuration change required is to add a constant, just to prevent SSR-specific styled-components code from being loaded on the client.
This shows how to use styled-components with preact-cli.
Styles are collected and inlined during pre-rendering, with no extra build or configuration step required.
The only configuration change required is to add a constant, just to prevent SSR-specific styled-components code from being loaded on the client.
| const { h } = require('preact'); | |
| const app = require('preact-cli-entrypoint-prerendering'); | |
| const prerender = app && app.default || app; | |
| if (typeof prerender !== 'function') { | |
| throw Error('prerender module must export a function, but exported '+(typeof prerender)); | |
| } | |
| module.exports = function(props) { | |
| const result = prerender(props); |