diff --git a/package.json b/package.json index 1ba27223..6fb10574 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "node": ">= 6.11.5" }, "peerDependencies": { + "style-loader": "^0.20.3", "webpack": "^4.4.0" }, "pre-commit": "lint-staged", diff --git a/src/loader.js b/src/loader.js index 44f7940b..f767f504 100644 --- a/src/loader.js +++ b/src/loader.js @@ -7,6 +7,7 @@ import NodeTargetPlugin from 'webpack/lib/node/NodeTargetPlugin'; import LibraryTemplatePlugin from 'webpack/lib/LibraryTemplatePlugin'; import SingleEntryPlugin from 'webpack/lib/SingleEntryPlugin'; import LimitChunkCountPlugin from 'webpack/lib/optimize/LimitChunkCountPlugin'; +import styleLoader from 'style-loader'; const NS = path.dirname(fs.realpathSync(__filename)); @@ -25,8 +26,13 @@ const findModuleById = (modules, id) => { return null; }; -export function pitch(request) { +export function pitch(request) { // eslint-disable-line consistent-return const query = loaderUtils.getOptions(this) || {}; + + if (query.hmr !== false) { + return styleLoader.pitch(request); + } + const loaders = this.loaders.slice(this.loaderIndex + 1); this.addDependency(this.resourcePath); const childFilename = '*'; // eslint-disable-line no-path-concat diff --git a/yarn.lock b/yarn.lock index 44411540..96fefdce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7436,6 +7436,13 @@ strip-json-comments@^2.0.1, strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" +style-loader@^0.20.3: + version "0.20.3" + resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.20.3.tgz#ebef06b89dec491bcb1fdb3452e913a6fd1c10c4" + dependencies: + loader-utils "^1.1.0" + schema-utils "^0.4.5" + suffix@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/suffix/-/suffix-0.1.0.tgz#3e46966de56af17600385e58db8ec659dd797907"