Skip to content

Commit

Permalink
fix(mini-css-extract): don't use loader in ssr (#29801) (#29809)
Browse files Browse the repository at this point in the history
(cherry picked from commit b2d6617)

Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
  • Loading branch information
GatsbyJS Bot and pieh authored Feb 26, 2021
1 parent fefa6b1 commit b667111
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ exports[`gatsby-plugin-less Stage: build-html / Less options #1 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down Expand Up @@ -62,7 +61,6 @@ exports[`gatsby-plugin-less Stage: build-html / Less options #2 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down Expand Up @@ -111,7 +109,6 @@ exports[`gatsby-plugin-less Stage: build-html / Loader options #1 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down Expand Up @@ -157,7 +154,6 @@ exports[`gatsby-plugin-less Stage: build-html / No options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down Expand Up @@ -202,7 +198,6 @@ exports[`gatsby-plugin-less Stage: build-html / PostCss plugins 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({\\"plugins\\":[\\"test1\\"]})",
Object {
Expand Down Expand Up @@ -247,7 +242,6 @@ exports[`gatsby-plugin-less Stage: build-html / css-loader options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"camelCase\\":false,\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down Expand Up @@ -968,7 +962,6 @@ exports[`gatsby-plugin-less Stage: develop-html / Less options #1 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down Expand Up @@ -1018,7 +1011,6 @@ exports[`gatsby-plugin-less Stage: develop-html / Less options #2 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down Expand Up @@ -1067,7 +1059,6 @@ exports[`gatsby-plugin-less Stage: develop-html / Loader options #1 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down Expand Up @@ -1113,7 +1104,6 @@ exports[`gatsby-plugin-less Stage: develop-html / No options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down Expand Up @@ -1158,7 +1148,6 @@ exports[`gatsby-plugin-less Stage: develop-html / PostCss plugins 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({\\"plugins\\":[\\"test1\\"]})",
Object {
Expand Down Expand Up @@ -1203,7 +1192,6 @@ exports[`gatsby-plugin-less Stage: develop-html / css-loader options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"camelCase\\":false,\\"modules\\":true,\\"importLoaders\\":2})",
"postcss({})",
Object {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-less/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ exports.onCreateWebpackConfig = (
const lessRuleModules = {
test: /\.module\.less$/,
use: [
loaders.miniCssExtract({ modules: true }),
!isSSR && loaders.miniCssExtract({ modules: true }),
loaders.css({ ...cssLoaderOptions, modules: true, importLoaders: 2 }),
loaders.postcss({ plugins: postCssPlugins }),
lessLoader,
],
].filter(Boolean),
}

const configRules = [
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-netlify-cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"html-webpack-plugin": "^5.2.0",
"html-webpack-tags-plugin": "^3.0.0",
"lodash": "^4.17.21",
"mini-css-extract-plugin": "^1.3.8",
"mini-css-extract-plugin": "1.3.9",
"netlify-identity-widget": "^1.9.1",
"webpack": "^5.23.00"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ exports[`gatsby-plugin-postcss Stage: build-html / Css options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.css\\$/,
"use": Array [
"miniCssExtract",
"css-loader({\\"camelCase\\":true,\\"importLoaders\\":1,\\"modules\\":true})",
Object {
"loader": "/resolved/path/postcss-loader",
Expand All @@ -31,7 +30,6 @@ exports[`gatsby-plugin-postcss Stage: build-html / Css options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.css\\$/,
"use": Array [
"miniCssExtract",
"css-loader({\\"camelCase\\":true,\\"importLoaders\\":1,\\"modules\\":true})",
Object {
"loader": "/resolved/path/postcss-loader",
Expand Down Expand Up @@ -145,7 +143,6 @@ exports[`gatsby-plugin-postcss Stage: build-html / No options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.css\\$/,
"use": Array [
"miniCssExtract",
"css-loader({\\"importLoaders\\":1,\\"modules\\":true})",
Object {
"loader": "/resolved/path/postcss-loader",
Expand Down Expand Up @@ -189,7 +186,6 @@ exports[`gatsby-plugin-postcss Stage: build-html / PostCss options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.css\\$/,
"use": Array [
"miniCssExtract",
"css-loader({\\"importLoaders\\":1,\\"modules\\":true})",
Object {
"loader": "/resolved/path/postcss-loader",
Expand All @@ -213,7 +209,6 @@ exports[`gatsby-plugin-postcss Stage: build-html / PostCss options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.css\\$/,
"use": Array [
"miniCssExtract",
"css-loader({\\"importLoaders\\":1,\\"modules\\":true})",
Object {
"loader": "/resolved/path/postcss-loader",
Expand Down Expand Up @@ -812,7 +807,6 @@ exports[`gatsby-plugin-postcss Stage: develop-html / Css options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.css\\$/,
"use": Array [
"miniCssExtract",
"css-loader({\\"camelCase\\":true,\\"importLoaders\\":1,\\"modules\\":true})",
Object {
"loader": "/resolved/path/postcss-loader",
Expand Down Expand Up @@ -926,7 +920,6 @@ exports[`gatsby-plugin-postcss Stage: develop-html / No options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.css\\$/,
"use": Array [
"miniCssExtract",
"css-loader({\\"importLoaders\\":1,\\"modules\\":true})",
Object {
"loader": "/resolved/path/postcss-loader",
Expand Down Expand Up @@ -970,7 +963,6 @@ exports[`gatsby-plugin-postcss Stage: develop-html / PostCss options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.css\\$/,
"use": Array [
"miniCssExtract",
"css-loader({\\"importLoaders\\":1,\\"modules\\":true})",
Object {
"loader": "/resolved/path/postcss-loader",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-postcss/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ exports.onCreateWebpackConfig = (
const postcssRuleModules = {
test: MODULE_CSS_PATTERN,
use: [
loaders.miniCssExtract({ modules: true }),
!isSSR && loaders.miniCssExtract({ modules: true }),
loaders.css({ ...cssLoaderOptions, importLoaders: 1, modules: true }),
postcssLoader,
],
].filter(Boolean),
}

const postcssRules = { oneOf: [postcssRuleModules, postcssRule] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ exports[`gatsby-plugin-sass Stage: build-html / No options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down Expand Up @@ -65,7 +64,6 @@ exports[`gatsby-plugin-sass Stage: build-html / PostCss plugins 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({\\"plugins\\":[\\"test1\\"]})",
Object {
Expand Down Expand Up @@ -118,7 +116,6 @@ exports[`gatsby-plugin-sass Stage: build-html / Sass options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down Expand Up @@ -181,7 +178,6 @@ exports[`gatsby-plugin-sass Stage: build-html / css-loader options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"camelCase\\":false,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down Expand Up @@ -234,7 +230,6 @@ exports[`gatsby-plugin-sass Stage: build-html / sass rule modules test options 1
Object {
"test": /\\\\\\.global\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down Expand Up @@ -287,7 +282,6 @@ exports[`gatsby-plugin-sass Stage: build-html / sass rule test options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down Expand Up @@ -1020,7 +1014,6 @@ exports[`gatsby-plugin-sass Stage: develop-html / No options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down Expand Up @@ -1073,7 +1066,6 @@ exports[`gatsby-plugin-sass Stage: develop-html / PostCss plugins 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({\\"plugins\\":[\\"test1\\"]})",
Object {
Expand Down Expand Up @@ -1126,7 +1118,6 @@ exports[`gatsby-plugin-sass Stage: develop-html / Sass options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down Expand Up @@ -1189,7 +1180,6 @@ exports[`gatsby-plugin-sass Stage: develop-html / css-loader options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"camelCase\\":false,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down Expand Up @@ -1242,7 +1232,6 @@ exports[`gatsby-plugin-sass Stage: develop-html / sass rule modules test options
Object {
"test": /\\\\\\.global\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down Expand Up @@ -1295,7 +1284,6 @@ exports[`gatsby-plugin-sass Stage: develop-html / sass rule test options 1`] = `
Object {
"test": /\\\\\\.module\\\\\\.s\\(a\\|c\\)ss\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2,\\"modules\\":true})",
"postcss({})",
Object {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-sass/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ exports.onCreateWebpackConfig = (
const sassRuleModules = {
test: sassRuleModulesTest || /\.module\.s(a|c)ss$/,
use: [
loaders.miniCssExtract({ modules: true }),
!isSSR && loaders.miniCssExtract({ modules: true }),
loaders.css({ importLoaders: 2, ...cssLoaderOptions, modules: true }),
loaders.postcss({ plugins: postCssPlugins }),
],
].filter(Boolean),
}
if (useResolveUrlLoader && !isSSR) {
sassRule.use.push({
Expand Down
Loading

0 comments on commit b667111

Please sign in to comment.