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

exclude Netlify CMS styles in build-css phase #3895

Merged
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
22 changes: 15 additions & 7 deletions packages/gatsby-plugin-netlify-cms/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,24 @@ function plugins(stage) {
}
}

/**
* Exclude Netlify CMS styles from Gatsby CSS bundle. This relies on Gatsby
* using webpack-configurator for webpack config extension, and also on the
* target loader key being named "css" in Gatsby's webpack config.
*/
function excludeFromLoader(key, config) {
config.loader(key, {
exclude: [/\/node_modules\/netlify-cms\//],
})
}

function module(config, stage) {
switch (stage) {
case `build-css`:
excludeFromLoader(`css`, config)
return config
case `build-javascript`:
// Exclude Netlify CMS styles from Gatsby CSS bundle. This relies on
// Gatsby using webpack-configurator for webpack config extension, and
// also on the target loader key being named "css" in Gatsby's webpack
// config.
config.loader(`css`, {
exclude: [/\/node_modules\/netlify-cms\//],
})
excludeFromLoader(`css`, config)

// Exclusively extract Netlify CMS styles to /cms.css (filename configured
// above with plugin instantiation).
Expand Down