Skip to content

Commit

Permalink
bring back null-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Feb 19, 2021
1 parent 0d6ff1f commit f66fef3
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,7 @@ exports[`gatsby-plugin-less Stage: build-html / Less options #1 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {
"modifyVars": Object {
"text-color": "#fff",
},
"strictMath": true,
},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -93,19 +80,7 @@ exports[`gatsby-plugin-less Stage: build-html / Less options #2 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {
"modifyVars": Object {
"text-color": "#fff",
},
},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -151,16 +126,7 @@ exports[`gatsby-plugin-less Stage: build-html / Loader options #1 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"appendData": "@env: test;",
"lessOptions": Object {},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -205,15 +171,7 @@ exports[`gatsby-plugin-less Stage: build-html / No options 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -258,15 +216,7 @@ exports[`gatsby-plugin-less Stage: build-html / PostCss plugins 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({\\"plugins\\":[\\"test1\\"]})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -311,15 +261,7 @@ exports[`gatsby-plugin-less Stage: build-html / css-loader options 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"camelCase\\":false,\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -1045,20 +987,7 @@ exports[`gatsby-plugin-less Stage: develop-html / Less options #1 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {
"modifyVars": Object {
"text-color": "#fff",
},
"strictMath": true,
},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -1107,19 +1036,7 @@ exports[`gatsby-plugin-less Stage: develop-html / Less options #2 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {
"modifyVars": Object {
"text-color": "#fff",
},
},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -1165,16 +1082,7 @@ exports[`gatsby-plugin-less Stage: develop-html / Loader options #1 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"appendData": "@env: test;",
"lessOptions": Object {},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -1219,15 +1127,7 @@ exports[`gatsby-plugin-less Stage: develop-html / No options 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -1272,15 +1172,7 @@ exports[`gatsby-plugin-less Stage: develop-html / PostCss plugins 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"importLoaders\\":2})",
"postcss({\\"plugins\\":[\\"test1\\"]})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {},
},
},
"null",
],
},
],
Expand Down Expand Up @@ -1325,15 +1217,7 @@ exports[`gatsby-plugin-less Stage: develop-html / css-loader options 1`] = `
Object {
"test": /\\\\\\.less\\$/,
"use": Array [
"miniCssExtract",
"css({\\"camelCase\\":false,\\"importLoaders\\":2})",
"postcss({})",
Object {
"loader": "/resolved/path/less-loader",
"options": Object {
"lessOptions": Object {},
},
},
"null",
],
},
],
Expand Down
17 changes: 10 additions & 7 deletions packages/gatsby-plugin-less/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import resolve from "./resolve"

exports.onCreateWebpackConfig = (
{ actions, loaders },
{ actions, stage, loaders },
{ cssLoaderOptions = {}, postCssPlugins, loaderOptions, lessOptions }
) => {
const isSSR = [`develop-html`, `build-html`].includes(stage)
const { setWebpackConfig } = actions

const lessLoader = {
Expand All @@ -18,12 +19,14 @@ exports.onCreateWebpackConfig = (

const lessRule = {
test: /\.less$/,
use: [
loaders.miniCssExtract(),
loaders.css({ ...cssLoaderOptions, importLoaders: 2 }),
loaders.postcss({ plugins: postCssPlugins }),
lessLoader,
],
use: isSSR
? [loaders.null()]
: [
loaders.miniCssExtract(),
loaders.css({ ...cssLoaderOptions, importLoaders: 2 }),
loaders.postcss({ plugins: postCssPlugins }),
lessLoader,
],
}
const lessRuleModules = {
test: /\.module\.less$/,
Expand Down
Loading

0 comments on commit f66fef3

Please sign in to comment.