Skip to content

Commit a0f7009

Browse files
fix: fixing docs
1 parent 9daf720 commit a0f7009

File tree

1 file changed

+45
-43
lines changed

1 file changed

+45
-43
lines changed

README.md

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,58 @@
1-
<div align="center">
2-
<img width="200" height="200" src="https://cdn.worldvectorlogo.com/logos/javascript.svg">
3-
<a href="https://webpack.js.org/">
4-
<img width="200" height="200" vspace="" hspace="25" src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon-square-big.svg">
5-
</a>
6-
<h1>extract-css-chunks-webpack-plugin</h1>
7-
</div>
8-
9-
[![npm][npm]][npm-url]
10-
[![node][node]][node-url]
11-
[![deps][deps]][deps-url]
12-
[![tests][tests]][tests-url]
13-
[![coverage][cover]][cover-url]
14-
[![chat][chat]][chat-url]
15-
[![size][size]][size-url]
1+
If you like our work, check out our Redux-based router <a href="https://github.com/faceyspacey/redux-first-router" target="_blank">redux-first-router</a> or its sucessor which, <a href="https://github.com/respond-framework/rudy" target="_blank">Rudy<a>
162

173
# extract-css-chunks-webpack-plugin
184

19-
This plugin extracts CSS into separate files. It creates a CSS file per JS file which contains CSS. It supports On-Demand-Loading of CSS and SourceMaps.
5+
<p align="center">
6+
<a href="https://www.npmjs.com/package/extract-css-chunks-webpack-plugin">
7+
<img src="https://img.shields.io/npm/v/extract-css-chunks-webpack-plugin.svg" alt="Version" />
8+
</a>
209

21-
It builds on top of a new webpack v4 feature (module types) and requires webpack 4 to work.
10+
<a href="https://travis-ci.org/faceyspacey/extract-css-chunks-webpack-plugin">
11+
<img src="https://travis-ci.org/faceyspacey/extract-css-chunks-webpack-plugin.svg?branch=master" alt="Build Status" />
12+
</a>
2213

23-
Compared to the extract-text-webpack-plugin:
14+
<a href="https://www.npmjs.com/package/extract-css-chunks-webpack-plugin">
15+
<img src="https://img.shields.io/npm/dt/extract-css-chunks-webpack-plugin.svg" alt="Downloads" />
16+
</a>
2417

25-
- Async loading
26-
- No duplicate compilation (performance)
27-
- Easier to use
28-
- Specific to CSS
18+
<a href="https://www.npmjs.com/package/extract-css-chunks-webpack-plugin">
19+
<img src="https://img.shields.io/npm/dm/extract-css-chunks-webpack-plugin.svg" alt="License" />
20+
</a>
21+
22+
<a href="https://www.npmjs.com/package/extract-css-chunks-webpack-plugin">
23+
<img src="https://img.shields.io/npm/l/extract-css-chunks-webpack-plugin.svg" alt="License" />
24+
</a>
25+
</p>
2926

30-
## Getting Started
27+
<h2 align="center">🍾🍾🍾It's our absolute pleasure to announce Webpack 4 Support 🚀🚀🚀</h2>
3128

32-
To begin, you'll need to install `extract-css-chunks-webpack-plugin`:
29+
> **HEADLINES (May 2018): Now Independently supports Webpack 4:**
30+
> 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!
3331
34-
```bash
35-
npm install --save-dev extract-css-chunks-webpack-plugin
36-
```
32+
So... why did we rebuild `extract-css-chunks`? What does it offer?
3733

38-
It's recommended to combine `extract-css-chunks-webpack-plugin` with the [`css-loader`](https://github.com/webpack-contrib/css-loader)
34+
It's got all the goodness of `mini-css-extract-plugin` but with 2 gleaming, sought after benefits.
3935

40-
Then add the loader and the plugin to your `webpack` config. For example:
36+
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:
4137

42-
**style.css**
38+
## Perks
4339

44-
```css
45-
body {
46-
background: green;
47-
}
48-
```
40+
- **HMR:** It also has first-class support for **Hot Module Replacement** across ALL those css files/chunks!!!
41+
- cacheable stylesheets
42+
- smallest total bytes sent compared to "render-path" css-in-js solutions that include your CSS definitions in JS
43+
- Faster than the V2!
44+
- Async loading
45+
- No duplicate compilation (performance)
46+
- Easier to use
47+
- Specific to CSS
48+
- SSR Friendly development build, focused on frontend DX
49+
- Works seamlessly with the Universal family
50+
- Works fantastically as a standalone style loader (You can use it for any webpack project! with no extra dependencies!)
51+
- Async styles do not render block webkit browsers, if you use the `insert` option
4952

50-
**component.js**
53+
Additionally, if you are already a user of the universal family -- we will be waving goodbye to the mandatory `window.__CSS_CHUNKS__`.
5154

52-
```js
53-
import './style.css';
54-
```
55+
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.
5556

5657
**webpack.config.js**
5758

@@ -63,6 +64,7 @@ module.exports = {
6364
module: {
6465
rules: [
6566
{
67+
test: /\.css$/i,
6668
test: /\.css$/i,
6769
use: [ExtractCssChunks.loader, 'css-loader'],
6870
},
@@ -317,7 +319,7 @@ module.exports = {
317319

318320
The `extract-css-chunks-webpack-plugin` supports hot reloading of actual css files in development.
319321
Some options are provided to enable HMR of both standard stylesheets and locally scoped CSS or CSS modules.
320-
Below is an example configuration of mini-css for HMR use with CSS modules.
322+
Below is an example configuration of `extract-css-chunks` for HMR use with CSS modules.
321323

322324
While we attempt to hmr css-modules. It is not easy to perform when code-splitting with custom chunk names.
323325
`reloadAll` is an option that should only be enabled if HMR isn't working correctly.
@@ -583,7 +585,7 @@ module.exports = {
583585
Type: `String|Function`
584586
Default: `head`
585587

586-
By default, the `mini-css-extract-plugin` appends styles (`<link>` elements) to `document.head` of the current `window`.
588+
By default, the `extract-css-chunks-plugin` appends styles (`<link>` elements) to `document.head` of the current `window`.
587589

588590
However in some circumstances it might be necessary to have finer control over the append target or even delay `link` elements instertion. For example this is the case when you asynchronously load styles for an application that runs inside of an iframe. In such cases `insert` can be configured to be a function or a custom selector.
589591

@@ -594,7 +596,7 @@ If you target an [iframe](https://developer.mozilla.org/en-US/docs/Web/API/HTMLI
594596
Allows to configure a [CSS selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) that will be used to find the element where to append the styles (`link` elements).
595597

596598
```js
597-
new MiniCssExtractPlugin({
599+
new ExtractCssChunksPlugin({
598600
insert: '#my-container',
599601
});
600602
```
@@ -610,7 +612,7 @@ Allows to override default behavior and insert styles at any position.
610612
> ⚠ The `insert` function is serialized to string and passed to the plugin. This means that it won't have access to the scope of the webpack configuration module.
611613
612614
```js
613-
new MiniCssExtractPlugin({
615+
new ExtractCssChunksPlugin({
614616
insert: function insert(linkTag) {
615617
const reference = document.querySelector('#some-element');
616618
if (reference) {

0 commit comments

Comments
 (0)