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(gatsby-plugin-netlify-cms): Don't use StaticQueryMapper #30599

Merged
merged 1 commit into from
Apr 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions packages/gatsby-plugin-netlify-cms/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ function deepMap(obj, fn) {
return obj
}

const cssTests = []

function replaceRule(value, stage) {
function replaceRule(value) {
// If `value` does not have a `test` property, it isn't a rule object.
if (!value || !value.test) {
return value
Expand Down Expand Up @@ -96,20 +94,6 @@ exports.onCreateWebpackConfig = (
return Promise.resolve()
}

// populate cssTests array later used by isCssRule
if (`develop` === stage) {
cssTests.push(
...[
rules.cssModules().test,
rules.css().test,
/\.s(a|c)ss$/,
/\.module\.s(a|c)ss$/,
/\.less$/,
/\.module\.less$/,
].map(t => t.toString())
)
}

const gatsbyConfig = getConfig()
const { program } = store.getState()
const publicPathClean = trim(publicPath, `/`)
Expand Down Expand Up @@ -161,15 +145,19 @@ exports.onCreateWebpackConfig = (
},
module: {
rules: deepMap(gatsbyConfig.module.rules, value =>
replaceRule(value, stage)
replaceRule(value)
).filter(Boolean),
},
plugins: [
// Remove plugins that either attempt to process the core Netlify CMS
// application, or that we want to replace with our own instance.
...gatsbyConfig.plugins.filter(
plugin =>
![`MiniCssExtractPlugin`, `GatsbyWebpackStatsExtractor`].find(
![
`MiniCssExtractPlugin`,
`GatsbyWebpackStatsExtractor`,
`StaticQueryMapper`,
].find(
pluginName =>
plugin.constructor && plugin.constructor.name === pluginName
)
Expand Down Expand Up @@ -210,7 +198,8 @@ exports.onCreateWebpackConfig = (
// Exclude CSS from index.html, as any imported styles are assumed to be
// targeting the editor preview pane. Uses `excludeAssets` option from
// `HtmlWebpackPlugin` config
// not compatible with webpack 5
// HtmlWebpackExcludeAssetsPlugin is not compatible with webpack 5
// TODO: Replace `html-webpack-exclude-assets-plugin` with `html-webpack-skip-assets-plugin`
// new HtmlWebpackExcludeAssetsPlugin(),

// Pass in needed Gatsby config values.
Expand Down