Skip to content

Commit 2e83dd0

Browse files
Merge pull request faceyspacey#69 from zackljackson/webpack-4
[WIP] Migrate Webpack 4 support branch
2 parents 1035f57 + 57df669 commit 2e83dd0

File tree

216 files changed

+25639
-3273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+25639
-3273
lines changed

.babelrc

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"useBuiltIns": true,
7+
"targets": {
8+
"node": "6.11.5"
9+
},
10+
"exclude": [
11+
"transform-async-to-generator",
12+
"transform-regenerator"
13+
]
14+
}
15+
]
16+
],
17+
"plugins": [
18+
[
19+
"transform-object-rest-spread",
20+
{
21+
"useBuiltIns": true
22+
}
23+
]
24+
],
25+
"env": {
26+
"test": {
27+
"presets": [
28+
"env"
29+
],
30+
"plugins": [
31+
"transform-object-rest-spread"
32+
]
33+
}
34+
}
35+
}

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ root = true
88
charset = utf-8
99
end_of_line = lf
1010
insert_final_newline = true
11-
indent_style = tab
11+
indent_style = space
1212
indent_size = 4
1313

1414
# Matches the exact files either package.json or .travis.yml

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/js/**/*.js

.eslintrc

-13
This file was deleted.

.eslintrc.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
parser: 'babel-eslint',
3+
parserOptions: {
4+
ecmaFeatures: {
5+
generators: true,
6+
experimentalObjectRestSpread: true
7+
},
8+
sourceType: 'module',
9+
allowImportExportEverywhere: false
10+
},
11+
extends: ['airbnb'],
12+
env: {
13+
'browser': true,
14+
},
15+
rules: {
16+
'no-param-reassign': 0,
17+
'func-names': 0,
18+
'no-underscore-dangle': 0,
19+
'no-restricted-syntax': 0,
20+
}
21+
};

.gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/node_modules
22

3-
/example/assets
4-
53
/test/js
64
/coverage
5+
/dist
76

87
/.idea
98

109
.DS_Store
11-
npm-debug.log
10+
*.log
11+
.eslintcache

ExtractedModule.js

-70
This file was deleted.

OrderUndefinedError.js

-14
This file was deleted.

README.md

+89-4
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,103 @@
1919
</a>
2020
</p>
2121

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).
2322

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+
25107

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.
27108

28-
For a demo, `git clone`: [universal-demo](https://github.com/faceyspacey/universal-demo)
29109

30110
*Note: this is a companion package to:*
31111
- [webpack-flush-chunks](https://github.com/faceyspacey/webpack-flush-chunks)
32112
- [react-universal-component](https://github.com/faceyspacey/react-universal-component)
33113
- [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)
34114

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)
35119

36120
## Recommended Installation
37121
```
@@ -260,3 +344,4 @@ We use [commitizen](https://github.com/commitizen/cz-cli), so run `npm run cm` t
260344
## More from FaceySpacey in Reactlandia
261345
- [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* 😎
262346

347+
</details>

example/base.css

-6
This file was deleted.

example/common.css

-5
This file was deleted.

example/dep.js

-2
This file was deleted.

example/dep2.js

-1
This file was deleted.

example/entry.js

-3
This file was deleted.

example/entry2.js

-4
This file was deleted.

example/image.png

-119 Bytes
Binary file not shown.

example/index.html

-12
This file was deleted.

example/style.css

-5
This file was deleted.

example/style2.css

-6
This file was deleted.

example/style3.css

-5
This file was deleted.

example/style4.css

-6
This file was deleted.

example/style5.1.css

-4
This file was deleted.

example/style5.2.css

-4
This file was deleted.

example/style5.css

-6
This file was deleted.

example/style6.css

-4
This file was deleted.

0 commit comments

Comments
 (0)