|
19 | 19 | </a>
|
20 | 20 | </p>
|
21 | 21 |
|
22 |
| -> **UPDATE (July 7th):** [babel-plugin-dual-import](https://github.com/faceyspacey/babel-plugin-dual-import) is now required to asynchronously import both css + js. *Much Faster Builds!* You likely want to read [its intro article](https://medium.com/@faceyspacey/webpacks-import-will-soon-fetch-js-css-here-s-how-you-do-it-today-4eb5b4929852). |
23 | 22 |
|
24 |
| -> **UPDATE (July 26th):** [babel-plugin-universal-import](https://github.com/faceyspacey/babel-plugin-universal-import) is what to use if you're using *React Universal Component*. |
| 23 | +> **HEADLINES (May 2018): Now Independently supports Webpack 4:** |
| 24 | +Yep that's right. The universal family is now fully Webpack 4. Thank you to all our users for your loyalty and patience! If you love Universal, then you are gonna fall head over heels when we bring out the main course! |
| 25 | + |
| 26 | +So... why did we rebuild `extract-css-chunks`? What does it offer? |
| 27 | + |
| 28 | +Its got all the goodness of `mini-css-extract-plugin` but with 2 gleaming, sought after benefits. |
| 29 | + |
| 30 | +Compared to the existing loaders, we are offering a single solution as opposed to needing to depend on multiple loaders to cater for different features: |
| 31 | + |
| 32 | +* Async loading |
| 33 | +* No duplicate compilation (performance) |
| 34 | +* Easier to use |
| 35 | +* Specific to CSS |
| 36 | +* True **Hot Module Reloading** - that means no `style-loader` |
| 37 | +* SSR Friendly development build, focused on frontend DX |
| 38 | +* Works seamlessly with the Universal family |
| 39 | +* Works fantastically as a standalone style loader (You can use it for any webpack project! with no extra dependencies!) |
| 40 | + |
| 41 | +Additionally, if you are already a user of the universal family -- we will be waving goodbye to the mandatory ```window.__CSS_CHUNKS__```. |
| 42 | + |
| 43 | +The functionality is still available to you via chunk flushing, and it can come in super handy when needing to easily resolve style assets as urls that might need to be passed to a third party. |
| 44 | + |
| 45 | + |
| 46 | +# BETA TESTING WEBPACK 4 |
| 47 | + |
| 48 | +If you want to test this alpha branch, which is currently not published to the NPM registry. |
| 49 | + |
| 50 | +Add the following to your package.json file, then `npm i` |
| 51 | + |
| 52 | + "extract-css-chunks-webpack-plugin": "git+ssh://git@github.com/zackljackson/extract-css-chunks-webpack-plugin.git#webpack-4", |
| 53 | + |
| 54 | + |
| 55 | +## Webpack 4 Standalone Installation: |
| 56 | + |
| 57 | +If you are just looking for something that works like `mini-css-extract-plugin` but with HMR. Then look no further |
| 58 | + |
| 59 | +NOTE: We have aligned out loader implementation to be the same as `mini-css-extract-plugin` |
| 60 | + |
| 61 | +**If you already use `mini-css-extract-plugin`, then you can just change the `require` statement - its that easy** |
| 62 | + |
| 63 | + |
| 64 | +**DONT USE THIS INSTALL CMD IF YOU ARE BETA TESTING:** |
| 65 | +``` |
| 66 | +yarn add --dev extract-css-chunks-webpack-plugin |
| 67 | +``` |
| 68 | + |
| 69 | +*webpack.config.js:* |
| 70 | +```js |
| 71 | +const ExtractCssChunks = require("extract-css-chunks-webpack-plugin") |
| 72 | + |
| 73 | +module.exports = { |
| 74 | + module: { |
| 75 | + rules: [ |
| 76 | + { |
| 77 | + test: /\.css$/, |
| 78 | + use: [ |
| 79 | + ExtractCssChunks.loader, |
| 80 | + "css-loader" |
| 81 | + ] |
| 82 | + } |
| 83 | + ] |
| 84 | + }, |
| 85 | + plugins: [ |
| 86 | + new ExtractCssChunks( |
| 87 | + { |
| 88 | + // Options similar to the same options in webpackOptions.output |
| 89 | + // both options are optional |
| 90 | + filename: "[name].css", |
| 91 | + chunkFilename: "[id].css" |
| 92 | + } |
| 93 | + ), |
| 94 | + ] |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | +### What about Webpack 3? |
| 101 | +This is a breaking change. The entire loader has been fundamentally rewritten specifically for Webpack 4. Aiming to support our existing user base, allowing them to upgrade their infrastructure to support Webpack 4 based universally code-split server-side rendered react applications. |
| 102 | + |
| 103 | +There have been some challenges along the way since the release of webpack 4. Ultimately the only remaining hurdle is code split, async style loading. |
| 104 | + |
| 105 | +If you do need Webpack 3, make sure to stick with the latest `v2.x.x` release. `v3.x.x` is only intend for users with Webpack 4 |
| 106 | + |
25 | 107 |
|
26 |
| -Like `extract-text-webpack-plugin`, but creates multiple css files (one per chunk). Then, as part of server side rendering, you can deliver just the css chunks needed by the current request. The result is the most minimal CSS initially served compared to emerging "render path" solutions. |
27 | 108 |
|
28 |
| -For a demo, `git clone`: [universal-demo](https://github.com/faceyspacey/universal-demo) |
29 | 109 |
|
30 | 110 | *Note: this is a companion package to:*
|
31 | 111 | - [webpack-flush-chunks](https://github.com/faceyspacey/webpack-flush-chunks)
|
32 | 112 | - [react-universal-component](https://github.com/faceyspacey/react-universal-component)
|
33 | 113 | - [babel-plugin-universal-import](https://github.com/faceyspacey/babel-plugin-universal-import) ***or*** [babel-plugin-dual-import](https://github.com/faceyspacey/babel-plugin-dual-import)
|
34 | 114 |
|
| 115 | +<details><summary>See Old Docs</summary> |
| 116 | +Like `extract-text-webpack-plugin`, but creates multiple css files (one per chunk). Then, as part of server side rendering, you can deliver just the css chunks needed by the current request. The result is the most minimal CSS initially served compared to emerging "render path" solutions. |
| 117 | + |
| 118 | +For a demo, `git clone`: [universal-demo](https://github.com/faceyspacey/universal-demo) |
35 | 119 |
|
36 | 120 | ## Recommended Installation
|
37 | 121 | ```
|
@@ -260,3 +344,4 @@ We use [commitizen](https://github.com/commitizen/cz-cli), so run `npm run cm` t
|
260 | 344 | ## More from FaceySpacey in Reactlandia
|
261 | 345 | - [redux-first-router](https://github.com/faceyspacey/redux-first-router). It's made to work perfectly with *Universal*. Together they comprise our *"frameworkless"* Redux-based approach to what Next.js does (splitting, SSR, prefetching, and routing). *People are lovin it by the way* 😎
|
262 | 346 |
|
| 347 | +</details> |
0 commit comments