Webpack
Preact Isomorphic CSS style loader forCSS style loader for Webpack that works similarly to
style-loader, but is optimized for
critical path CSS
rendering and also works great in the context of
isomorphic apps.
It provides two helper methods on to the styles
object - ._insertCss()
(injects CSS into the DOM) and ._getCss()
(returns a CSS string).
See getting started | changelog | Join #react-starter-kit chat room on Gitter to stay up to date
How to Install
$ npm install preact-isomorphic-style-loader --save-dev
Getting Started
Webpack configuration:
moduleexports = /* ... */ module: rules: test: /\.css$/ use: 'preact-isomorphic-style-loader' loader: 'css-loader' options: importLoaders: 1 'postcss-loader' /* ... */
Note: Configuration is the same for both client-side and server-side bundles. For more information visit https://webpack.js.org/configuration/module/.
React component example:
/* App.css */
/* App.js */ // you can use decorator @withStyles(style) and export App { return <div className=sroot> <h1 className=stitle>Hello world!</h1> </div> } sApp
See server-side rendering example below:
;; const server = const port = processenvPORT || 3000 // Server-side rendering of the React appserver server