-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[gatsby-plugin-netlify-cms] Enabling preview styles #6641
Comments
Do the styles work in production? |
Yes, it's just in the CMS preview. The preview even generates the correct HTML, with the correct CSS module classnames. It just isn't building the styles bundle. |
There was another issue like this, see: decaporg/gatsby-starter-decap-cms#19 For the record I'm having similar issues getting styling to work in Gatsby v2, but linking in case its relevant to you. In my case, I can't get even the class names to actually apply to the stuff in the preview so it all just looks like plain text. You're one step ahead of me. |
The comment on that thread talks about it generating styles.css. My issue is that that file isn't being generated. |
I don't think this is the issue but another thing I'm looking at here is that you're calling |
I tried it with various combinations. From what I understand, the setting in |
No, I don't think so. Take a look here at cms.js: // eslint-disable-next-line no-undef
if (NETLIFY_CMS_PREVIEW_STYLES_SET) {
CMS.registerPreviewStyle(`styles.css`)
} And here in gatsby-node.js plugins.define({
NETLIFY_CMS_PREVIEW_STYLES_SET: !!stylesPath,
}), The plugin is directly calling the Per the documentation here, you can pass a path or array of paths to the option. Changing my config to provide it with the path to the css file that is used by my site rendered some of the styles in the preview pane. My case is probably a bit simpler though because all the styles are contained within actual css files. |
The bit in |
Yeah you're right. I'll post back if I find more! |
@ascorbic try making the Netlify CMS plugin last (except for any plugins that also require being last, like |
Ah, disregard, just noticed your config in your original post. |
@ascorbic I took the liberty of forking your repo and checking things out locally - styles seem to be working. You'll want to remove the Run the develop task and check out Hope that makes sense lol. Closing for now, please comment if you have further issues. |
@erquhart Thanks. Unfortunately that doesn't work. The issue is that I'm using CSS modules. Importing |
Can you test out #6871 and see if it works for you? With that, any imported styles in your |
Ah, that looks like a much better approach. I have a branch with Netlify CMS 2, so I'll try it with that and let you know. If you could merge decaporg/decap-cms#1543 it would be even better ;) |
I can confirm that #6871 fixes this. |
Summary
I'm not sure how to get Netlify CMS to display custom preview styles.
Relevant information
I am using Netlify CMS with custom preview components that use CSS modules. It's unclear how to get the styles to be generated and loaded. Particularly, I don't know what I should be putting in
stylesPath
in the config. All of the styles are imported in the components, so there is no entry point as such. I tried setting the path to point to one of the base stylesheets, butstyles.css
is not generated. There is astyles.js
file created bymini-css-extract-plugin
, but no matching CSS.Environment (if relevant)
File contents (if changed)
gatsby-config.js
:package.json
:gatsby-node.js
:gatsby-browser.js
: N/Agatsby-ssr.js
: N/AThe text was updated successfully, but these errors were encountered: