Skip to content

Commit

Permalink
fix(core): Disable HMR for CSS modules (#11032)
Browse files Browse the repository at this point in the history
* Disable HMR for CSS modules
  • Loading branch information
jonlow authored and wardpeet committed Jan 31, 2019
1 parent 123172c commit 97c98e9
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-less/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.onCreateWebpackConfig = (
const lessRuleModules = {
test: /\.module\.less$/,
use: [
!isSSR && loaders.miniCssExtract(),
!isSSR && loaders.miniCssExtract({ hmr: false }),
loaders.css({ ...cssLoaderOptions, modules: true, importLoaders: 2 }),
loaders.postcss({ plugins: postCssPlugins }),
lessLoader,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-postcss/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ exports.onCreateWebpackConfig = (

if (!isSSR) {
postcssRule.use.unshift(loaders.miniCssExtract())
postcssRuleModules.use.unshift(loaders.miniCssExtract())
postcssRuleModules.use.unshift(loaders.miniCssExtract({ hmr: false }))
}

const postcssRules = { oneOf: [] }
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-sass/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.onCreateWebpackConfig = (
const sassRuleModules = {
test: /\.module\.s(a|c)ss$/,
use: [
!isSSR && loaders.miniCssExtract(),
!isSSR && loaders.miniCssExtract({ hmr: false }),
loaders.css({ ...cssLoaderOptions, modules: true, importLoaders: 2 }),
loaders.postcss({ plugins: postCssPlugins }),
sassLoader,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-stylus/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ exports.onCreateWebpackConfig = (
const stylusRuleModules = {
test: /\.module\.styl$/,
use: [
!isSSR && loaders.miniCssExtract(),
!isSSR && loaders.miniCssExtract({ hmr: false }),
loaders.css({ modules: true, importLoaders: 2 }),
loaders.postcss({ plugins: postCssPlugins }),
stylusLoader,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/utils/webpack-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ module.exports = async ({
loaders.css({ ...options, importLoaders: 1 }),
loaders.postcss({ browsers }),
]
if (!isSSR) use.unshift(loaders.miniCssExtract())
if (!isSSR) use.unshift(loaders.miniCssExtract({ hmr: !options.modules }))

return {
use,
Expand Down

0 comments on commit 97c98e9

Please sign in to comment.