Skip to content

Commit

Permalink
exclude Netlify CMS styles in build-css phase (#3895)
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart authored and KyleAMathews committed Feb 7, 2018
1 parent fc71785 commit 484e5ae
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

2 comments on commit 484e5ae

@Jaikant
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this change have probably broken something. The plugin was working well a few weeks back, but is now giving the below error on build:

success Building CSS — 6.168 s

error Generating JavaScript bundles failed

  Error: ./~/netlify-cms/dist/cms.js
  Module parse failed:  .../node_modules/netlify-cms/dist/cms.js Unexpected token (174:70542)
  You may need an appropriate loader to handle this file type.
  SyntaxError: Unexpected token (174:70542)
      at Parser.pp$4.raise ( .../node_modules/acorn/dist/acorn.js:2221:15)

@m-allanson
Copy link
Contributor

@m-allanson m-allanson commented on 484e5ae Feb 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jaikant I think this is fixed in #4046. Also see #4031.

Please sign in to comment.