From c644b00f3ea17ec553ade6457439bffeef7dae54 Mon Sep 17 00:00:00 2001 From: Zack Jackson Date: Mon, 8 Oct 2018 15:01:50 -0700 Subject: [PATCH 1/3] docs(readme): Tone of Voice clairification on what hot:true does (#113) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dbce0e7b..549a7951 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ module.exports = { // both options are optional filename: "[name].css", chunkFilename: "[id].css", - hot: true, // optional as the plugin cannot automatically detect if you are using HOT, not for production use + hot: true, // if you want HMR - we try to automatically inject hot reloading but if it's not working, add it to the config orderWarning: true, // Disable to remove warnings about conflicting order between imports reloadAll: true, // when desperation kicks in - this is a brute force HMR flag cssModules: true // if you use cssModules, this can help. From 196fc39c1fb279b058c26c1f0ba961b4467d4088 Mon Sep 17 00:00:00 2001 From: Sebastian Seilund Date: Tue, 9 Oct 2018 09:59:37 -0700 Subject: [PATCH 2/3] fix(index.js): Support function loaders updateWebpackConfig previously expected `use` entries to be strings or arrays, and would throw `needle.includes is not a function` errors when given a function that returns a loader object. --- src/index.js | 3 +++ test/cases/function-loader/expected/main.css | 2 ++ test/cases/function-loader/index.js | 1 + test/cases/function-loader/style.css | 1 + test/cases/function-loader/webpack.config.js | 21 ++++++++++++++++++++ 5 files changed, 28 insertions(+) create mode 100644 test/cases/function-loader/expected/main.css create mode 100644 test/cases/function-loader/index.js create mode 100644 test/cases/function-loader/style.css create mode 100644 test/cases/function-loader/webpack.config.js diff --git a/src/index.js b/src/index.js index 935d8203..0cd15048 100644 --- a/src/index.js +++ b/src/index.js @@ -426,6 +426,9 @@ class ExtractCssChunks { this.traverseDepthFirst(rule, (node) => { if (node && node.use && Array.isArray(node.use)) { const isMiniCss = node.use.some((l) => { + if (typeof l === 'function') { + return false; + } const needle = l.loader || l; return needle.includes(pluginName); }); diff --git a/test/cases/function-loader/expected/main.css b/test/cases/function-loader/expected/main.css new file mode 100644 index 00000000..aea53e43 --- /dev/null +++ b/test/cases/function-loader/expected/main.css @@ -0,0 +1,2 @@ +body { background: red; } + diff --git a/test/cases/function-loader/index.js b/test/cases/function-loader/index.js new file mode 100644 index 00000000..aa3357bf --- /dev/null +++ b/test/cases/function-loader/index.js @@ -0,0 +1 @@ +import './style.css'; diff --git a/test/cases/function-loader/style.css b/test/cases/function-loader/style.css new file mode 100644 index 00000000..31fc5b8a --- /dev/null +++ b/test/cases/function-loader/style.css @@ -0,0 +1 @@ +body { background: red; } diff --git a/test/cases/function-loader/webpack.config.js b/test/cases/function-loader/webpack.config.js new file mode 100644 index 00000000..0137a9e4 --- /dev/null +++ b/test/cases/function-loader/webpack.config.js @@ -0,0 +1,21 @@ +const Self = require('../../../'); + +module.exports = { + entry: './index.js', + module: { + rules: [ + { + test: /\.css$/, + use: [ + () => ({ loader: 'css-loader' }), + ], + }, + ], + }, + plugins: [ + new Self({ + filename: '[name].css', + hot: true, + }), + ], +}; From 1294769727ee0f82ade8245f5e3e0963b606c7d0 Mon Sep 17 00:00:00 2001 From: Zack Jackson Date: Tue, 9 Oct 2018 10:05:35 -0700 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 549a7951..dbce0e7b 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ module.exports = { // both options are optional filename: "[name].css", chunkFilename: "[id].css", - hot: true, // if you want HMR - we try to automatically inject hot reloading but if it's not working, add it to the config + hot: true, // optional as the plugin cannot automatically detect if you are using HOT, not for production use orderWarning: true, // Disable to remove warnings about conflicting order between imports reloadAll: true, // when desperation kicks in - this is a brute force HMR flag cssModules: true // if you use cssModules, this can help.