Skip to content

Commit

Permalink
exclude Netlify CMS styles in build-css phase
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart committed Feb 7, 2018
1 parent 049c322 commit b069c60
Showing 1 changed file with 15 additions and 7 deletions.
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

0 comments on commit b069c60

Please sign in to comment.