Skip to content

[WIP] Migrate Webpack 4 support branch #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"presets": [
[
"env",
{
"useBuiltIns": true,
"targets": {
"node": "6.11.5"
},
"exclude": [
"transform-async-to-generator",
"transform-regenerator"
]
}
]
],
"plugins": [
[
"transform-object-rest-spread",
{
"useBuiltIns": true
}
]
],
"env": {
"test": {
"presets": [
"env"
],
"plugins": [
"transform-object-rest-spread"
]
}
}
}
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ root = true
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_style = space
indent_size = 4

# Matches the exact files either package.json or .travis.yml
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/js/**/*.js
13 changes: 0 additions & 13 deletions .eslintrc

This file was deleted.

21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
generators: true,
experimentalObjectRestSpread: true
},
sourceType: 'module',
allowImportExportEverywhere: false
},
extends: ['airbnb'],
env: {
'browser': true,
},
rules: {
'no-param-reassign': 0,
'func-names': 0,
'no-underscore-dangle': 0,
'no-restricted-syntax': 0,
}
};
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/node_modules

/example/assets

/test/js
/coverage
/dist

/.idea

.DS_Store
npm-debug.log
*.log
.eslintcache
70 changes: 0 additions & 70 deletions ExtractedModule.js

This file was deleted.

14 changes: 0 additions & 14 deletions OrderUndefinedError.js

This file was deleted.

93 changes: 89 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,103 @@
</a>
</p>

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

> **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*.
> **HEADLINES (May 2018): Now Independently supports Webpack 4:**
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!

So... why did we rebuild `extract-css-chunks`? What does it offer?

Its got all the goodness of `mini-css-extract-plugin` but with 2 gleaming, sought after benefits.

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:

* Async loading
* No duplicate compilation (performance)
* Easier to use
* Specific to CSS
* True **Hot Module Reloading** - that means no `style-loader`
* SSR Friendly development build, focused on frontend DX
* Works seamlessly with the Universal family
* Works fantastically as a standalone style loader (You can use it for any webpack project! with no extra dependencies!)

Additionally, if you are already a user of the universal family -- we will be waving goodbye to the mandatory ```window.__CSS_CHUNKS__```.

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.


# BETA TESTING WEBPACK 4

If you want to test this alpha branch, which is currently not published to the NPM registry.

Add the following to your package.json file, then `npm i`

"extract-css-chunks-webpack-plugin": "git+ssh://[email protected]/zackljackson/extract-css-chunks-webpack-plugin.git#webpack-4",


## Webpack 4 Standalone Installation:

If you are just looking for something that works like `mini-css-extract-plugin` but with HMR. Then look no further

NOTE: We have aligned out loader implementation to be the same as `mini-css-extract-plugin`

**If you already use `mini-css-extract-plugin`, then you can just change the `require` statement - its that easy**


**DONT USE THIS INSTALL CMD IF YOU ARE BETA TESTING:**
```
yarn add --dev extract-css-chunks-webpack-plugin
```

*webpack.config.js:*
```js
const ExtractCssChunks = require("extract-css-chunks-webpack-plugin")

module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
ExtractCssChunks.loader,
"css-loader"
]
}
]
},
plugins: [
new ExtractCssChunks(
{
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].css",
chunkFilename: "[id].css"
}
),
]
}
```



### What about Webpack 3?
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.

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.

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


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.

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

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

<details><summary>See Old Docs</summary>
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.

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

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

</details>
6 changes: 0 additions & 6 deletions example/base.css

This file was deleted.

5 changes: 0 additions & 5 deletions example/common.css

This file was deleted.

2 changes: 0 additions & 2 deletions example/dep.js

This file was deleted.

1 change: 0 additions & 1 deletion example/dep2.js

This file was deleted.

3 changes: 0 additions & 3 deletions example/entry.js

This file was deleted.

4 changes: 0 additions & 4 deletions example/entry2.js

This file was deleted.

Binary file removed example/image.png
Binary file not shown.
12 changes: 0 additions & 12 deletions example/index.html

This file was deleted.

5 changes: 0 additions & 5 deletions example/style.css

This file was deleted.

6 changes: 0 additions & 6 deletions example/style2.css

This file was deleted.

5 changes: 0 additions & 5 deletions example/style3.css

This file was deleted.

6 changes: 0 additions & 6 deletions example/style4.css

This file was deleted.

4 changes: 0 additions & 4 deletions example/style5.1.css

This file was deleted.

4 changes: 0 additions & 4 deletions example/style5.2.css

This file was deleted.

6 changes: 0 additions & 6 deletions example/style5.css

This file was deleted.

4 changes: 0 additions & 4 deletions example/style6.css

This file was deleted.

Loading