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

Updating the build pipeline to include custom CMS templates for preview #678

Closed
maxcell opened this issue Jul 8, 2022 · 1 comment · Fixed by #705
Closed

Updating the build pipeline to include custom CMS templates for preview #678

maxcell opened this issue Jul 8, 2022 · 1 comment · Fixed by #705
Labels

Comments

@maxcell
Copy link
Contributor

maxcell commented Jul 8, 2022

Summary

Looks like when I upgraded all of our dependencies and fixed up some breaking changes in #674, I also broke the Preview Template feature. Fortunately this doesn't stop it from rendering properly once you've published your post in the editor, just need to find a way to bring the src/js/cms.js files into our site/static/admin/index.html.

Current Preview Current Output
CleanShot 2022-07-08 at 17 12 36 CleanShot 2022-07-08 at 17 29 42

Steps to Reproduce

To reproduce this you need to go into the NetlifyCMS (/admin) and see any page or post.

Expected Behavior

We should expect the current output as the current preview, with the same styling and everything we're using.

@maxcell maxcell added the bug label Jul 8, 2022
@cgc
Copy link

cgc commented Sep 15, 2022

Seems like the issue might have been introduced in be22c5f, which loads netlify-cms from unpkg instead of the included cms.js file:

--- a/src/cms.html
+++ b/site/static/admin/index.html
@@ -9,6 +9,6 @@
   <script src="https://identity-js.netlify.com/v1/netlify-identity-widget.js"></script>
 </head>
 <body>
-  <script src="<%= htmlWebpackPlugin.files.chunks.cms.entry %>"></script>
+  <script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
 </body>
 </html>

I was able to get a fix working on my site -- here are the changes pulled out into a commit cgc@97a313e. They deal with breaking changes in two packages during the version updates in #674:

  • date-fns - format strings changed in 2.0, the release notes have a table of changes here
  • html-webpack-plugin - htmlWebpackPlugin.files has a new format that disappointingly discards bundle names between 3.x and 4.x (documented in project readme, search for "htmlWebpackPlugin.files"). The change is a bit annoying because it means you have to assume the order of bundles. Since object property order is based on insertion order (in ES6), as long as that order isn't modified by webpack, the index in my commit is appropriate for the order of bundles in webpack.common.js (empirically, it also works). An issue to reverse this change (so, to once again access bundles by name) has been opened but is stale: Can't get assets by entry point chunk name in v4 jantimon/html-webpack-plugin#1369.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants