Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mini-css-extract): don't use loader in ssr (#29801) #29809

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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