babel-plugin-dual-import
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "babel-plugin-dual-import", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Babel plugin to import() both js + css", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -103,2 +103,44 @@ # babel-plugin-dual-import [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg?style=flat-square)](https://gitter.im/faceyspacey/Lobby) | ||
## Usage with [react-universal-component](https://github.com/faceyspacey/react-universal-component) and [webpack-flush-chunks](https://github.com/faceyspacey/webpack-flush-chunks) | ||
When using `webpack-flush-chunks` you will have to supply the `chunkNames` option, not the `moduleIds` option since this plugin is based on chunk names. Here's an example: | ||
*src/components/App.js:* | ||
```js | ||
const UniversalComponent = universal(() => import('./Foo'), { | ||
resolve: () => require.resolveWeak('./Foo'), | ||
chunkName: 'Foo' | ||
}) | ||
const UniversalDynamicComponent = universal(() => import(`./base/${page}`), { | ||
resolve: ({ page }) => require.resolveWeak(`./base/${page}`), | ||
chunkName: ({ page }) => `base/${page}` | ||
}) | ||
``` | ||
*server/render.js:* | ||
```js | ||
import { flushChunkNames } from 'react-universal-component/server' | ||
import flushChunks from 'webpack-flush-chunks' | ||
const app = ReactDOMServer.renderToString(<App />) | ||
const { js, styles, cssHash } = flushChunks(webpackStats, { | ||
chunkNames: flushChunkNames() | ||
}) | ||
res.send(` | ||
<!doctype html> | ||
<html> | ||
<head> | ||
${styles} | ||
</head> | ||
<body> | ||
<div id="root">${app}</div> | ||
${js} | ||
${cssHash} | ||
</body> | ||
</html> | ||
`) | ||
``` | ||
## Babel Server Or Webpack < 2.2.20 | ||
@@ -105,0 +147,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
366564
169