Skip to content

Commit 63d961a

Browse files
committed
hmr support
1 parent e200b08 commit 63d961a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"node": ">= 6.11.5"
5757
},
5858
"peerDependencies": {
59+
"style-loader": "^0.20.3",
5960
"webpack": "^4.4.0"
6061
},
6162
"pre-commit": "lint-staged",

src/loader.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import NodeTargetPlugin from 'webpack/lib/node/NodeTargetPlugin';
77
import LibraryTemplatePlugin from 'webpack/lib/LibraryTemplatePlugin';
88
import SingleEntryPlugin from 'webpack/lib/SingleEntryPlugin';
99
import LimitChunkCountPlugin from 'webpack/lib/optimize/LimitChunkCountPlugin';
10+
import styleLoader from 'style-loader';
1011

1112
const NS = path.dirname(fs.realpathSync(__filename));
1213

@@ -25,8 +26,13 @@ const findModuleById = (modules, id) => {
2526
return null;
2627
};
2728

28-
export function pitch(request) {
29+
export function pitch(request) { // eslint-disable-line consistent-return
2930
const query = loaderUtils.getOptions(this) || {};
31+
32+
if (query.hmr !== false) {
33+
return styleLoader.pitch(request);
34+
}
35+
3036
const loaders = this.loaders.slice(this.loaderIndex + 1);
3137
this.addDependency(this.resourcePath);
3238
const childFilename = '*'; // eslint-disable-line no-path-concat

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7436,6 +7436,13 @@ strip-json-comments@^2.0.1, strip-json-comments@~2.0.1:
74367436
version "2.0.1"
74377437
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
74387438

7439+
style-loader@^0.20.3:
7440+
version "0.20.3"
7441+
resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.20.3.tgz#ebef06b89dec491bcb1fdb3452e913a6fd1c10c4"
7442+
dependencies:
7443+
loader-utils "^1.1.0"
7444+
schema-utils "^0.4.5"
7445+
74397446
suffix@^0.1.0:
74407447
version "0.1.0"
74417448
resolved "https://registry.yarnpkg.com/suffix/-/suffix-0.1.0.tgz#3e46966de56af17600385e58db8ec659dd797907"

0 commit comments

Comments
 (0)