Skip to content

Commit b116312

Browse files
Merge branch 'master' into css-module-oneof-hmr
# Conflicts: # src/index.js
2 parents 9a41708 + beadad5 commit b116312

File tree

8 files changed

+160
-130
lines changed

8 files changed

+160
-130
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4+
5+
<a name="3.2.0"></a>
6+
# [3.2.0](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/compare/v3.1.2...v3.2.0) (2018-10-08)
7+
8+
9+
### Features
10+
11+
* **readme:** Documenting new options that have been added ([#112](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/issues/112)) ([94ee96e](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/commit/94ee96e))

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ module.exports = {
9090
// both options are optional
9191
filename: "[name].css",
9292
chunkFilename: "[id].css",
93-
hot: true // optional as the plugin cannot automatically detect if you are using HOT, not for production use
93+
hot: true, // optional as the plugin cannot automatically detect if you are using HOT, not for production use
94+
orderWarning: true, // Disable to remove warnings about conflicting order between imports
95+
reloadAll: true, // when desperation kicks in - this is a brute force HMR flag
96+
cssModules: true // if you use cssModules, this can help.
9497
}
9598
),
9699
]
@@ -194,7 +197,7 @@ module.exports = {
194197
}
195198
},
196199
plugins: [
197-
new ExtractCssChunks({hot:true}), //if you want HMR - we try to automatically inject hot reloading but if it's not working, add it to the config
200+
new ExtractCssChunks({hot:true, cssModules: true}), //if you want HMR - we try to automatically inject hot reloading but if it's not working, add it to the config
198201
]
199202
};
200203
```

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "extract-css-chunks-webpack-plugin",
3-
"version": "0.0.0-placeholder",
3+
"version": "3.2.0",
44
"author": "James Gillmore <james@faceyspacey.com>",
55
"contributors": [
66
"Zack Jackson <zack@ScriptedAlchemy.com> (https://github.com/ScriptedAlchemy)"
77
],
8-
"description": "Extract CSS from chunks into stylesheets + HMR. Supports Webpack 4",
8+
"description": "Extract CSS from chunks into stylesheets + HMR. Supports Webpack 4 + SSR",
99
"engines": {
1010
"node": ">= 6.9.0 <7.0.0 || >= 8.9.0"
1111
},
@@ -24,7 +24,9 @@
2424
"hmr",
2525
"universal",
2626
"webpack",
27-
"webpack 4"
27+
"webpack 4",
28+
"css-hot-loader",
29+
"extract-css-chunks-webpack-plugin"
2830
],
2931
"license": "MIT",
3032
"scripts": {
@@ -86,7 +88,7 @@
8688
"nsp": "^3.1.0",
8789
"pre-commit": "^1.2.2",
8890
"prettier": "^1.11.1",
89-
"standard-version": "^4.3.0",
91+
"standard-version": "^4.4.0",
9092
"webpack": "4.8.3",
9193
"webpack-cli": "^2.0.13",
9294
"webpack-dev-server": "^3.1.1"

src/hotLoader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const loaderUtils = require('loader-utils');
33

44
const defaultOptions = {
55
fileMap: '{fileName}',
6+
cssModules: true,
67
};
78

89
module.exports = function (content) {
@@ -13,7 +14,7 @@ module.exports = function (content) {
1314
loaderUtils.getOptions(this),
1415
);
1516

16-
const accept = options.cssModule ? '' : 'module.hot.accept(undefined, cssReload);';
17+
const accept = options.cssModules ? '' : 'module.hot.accept(undefined, cssReload);';
1718
return content + `
1819
if(module.hot) {
1920
// ${Date.now()}

src/hotModuleReplacement.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ function updateCss(el, url) {
5353
const newEl = el.cloneNode();
5454

5555
newEl.isLoaded = false;
56+
5657
newEl.addEventListener('load', function () {
5758
newEl.isLoaded = true;
58-
el.remove();
59+
el.parentNode.removeChild(el);
5960
});
61+
6062
newEl.addEventListener('error', function () {
6163
newEl.isLoaded = true;
62-
el.remove();
64+
el.parentNode.removeChild(el);
6365
});
6466

6567
newEl.href = url + '?' + Date.now();

0 commit comments

Comments
 (0)