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

Sanity V3 Embedding System don't load styles #27

Open
Rychillie opened this issue Aug 9, 2022 · 5 comments
Open

Sanity V3 Embedding System don't load styles #27

Rychillie opened this issue Aug 9, 2022 · 5 comments

Comments

@Rychillie
Copy link

When i use the new Sanity.io embedding system the page crashes and it is not possible to run the app because it cannot find the react-mde CSS

Global CSS cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-npm
Location: node_modules/sanity-plugin-markdown/lib/index.modern.js

image

@gino
Copy link

gino commented Aug 16, 2022

Having the same issues here, using Next.js along with next-sanity.

@yeskunall
Copy link

yeskunall commented Aug 26, 2022

This is still broken as of v3.0.0-v3-studio.1.

The latest version also drops support for drag-and-drop image uploads.

EDIT: @uiw/readt-markdown-editor also does not support writing MDX.

@ehowey
Copy link

ehowey commented Nov 9, 2022

Just hopping in here to also state that I just saw this error /w NextJS 13 and the latest version of the plugin (3.0.0-v3-studio.7). I have the studio setup inside of NextJS as a page route - identical to how it is done here: https://github.com/sanity-io/nextjs-blog-cms-sanity-v3

error - ./node_modules/@uiw/react-markdown-preview/esm/styles/markdown.css
Global CSS cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-npm
Location: node_modules/@uiw/react-markdown-preview/esm/index.js
error - Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/erichowey/coding/ehdev-v3/node_modules/react-markdown/index.js from /Users/erichowey/coding/ehdev-v3/node_modules/@uiw/react-markdown-preview/lib/index.js not supported.
Instead change the require of /Users/erichowey/coding/ehdev-v3/node_modules/react-markdown/index.js in /Users/erichowey/coding/ehdev-v3/node_modules/@uiw/react-markdown-preview/lib/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/erichowey/coding/ehdev-v3/node_modules/@uiw/react-markdown-preview/lib/index.js:13:45)
    at Object.<anonymous> (/Users/erichowey/coding/ehdev-v3/node_modules/@uiw/react-md-editor/lib/Editor.js:13:52)
    at Object.<anonymous> (/Users/erichowey/coding/ehdev-v3/node_modules/@uiw/react-md-editor/lib/index.js:12:39)
    at Object.<anonymous> (/Users/erichowey/coding/ehdev-v3/node_modules/sanity-plugin-markdown/lib/index.js:1:448)
    at Object.sanity-plugin-markdown (/Users/erichowey/coding/ehdev-v3/.next/server/pages/studio/[[...index]].js:142:18)
    at __webpack_require__ (/Users/erichowey/coding/ehdev-v3/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///./sanity.config.ts:13:80)
    at Object../sanity.config.ts (/Users/erichowey/coding/ehdev-v3/.next/server/pages/studio/[[...index]].js:42:1)
    at __webpack_require__ (/Users/erichowey/coding/ehdev-v3/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///./pages/studio/[[...index]].tsx:9:72)
    at Function.__webpack_require__.a (/Users/erichowey/coding/ehdev-v3/.next/server/webpack-runtime.js:97:13)
    at eval (webpack-internal:///./pages/studio/[[...index]].tsx:1:21)
    at Object../pages/studio/[[...index]].tsx (/Users/erichowey/coding/ehdev-v3/.next/server/pages/studio/[[...index]].js:32:1)
    at __webpack_require__ (/Users/erichowey/coding/ehdev-v3/.next/server/webpack-runtime.js:33:42)
    at __webpack_exec__ (/Users/erichowey/coding/ehdev-v3/.next/server/pages/studio/[[...index]].js:172:39)
    at /Users/erichowey/coding/ehdev-v3/.next/server/pages/studio/[[...index]].js:173:28
    at Object.<anonymous> (/Users/erichowey/coding/ehdev-v3/.next/server/pages/studio/[[...index]].js:176:3)
    at Object.requirePage (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/require.js:88:12)
    at /Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/load-components.js:37:73
    at runMicrotasks (<anonymous>)
    at async Object.loadComponents (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/load-components.js:37:26)
    at async DevServer.findPageComponents (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/next-server.js:550:36)
    at async DevServer.renderPageComponent (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/base-server.js:916:24)
    at async DevServer.renderToResponse (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/base-server.js:955:36)
    at async DevServer.pipe (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/base-server.js:404:25)
    at async Object.fn (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/next-server.js:746:21)
    at async Router.execute (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/router.js:252:36)
    at async DevServer.run (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/base-server.js:381:29)
    at async DevServer.run (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/dev/next-dev-server.js:732:20)
    at async DevServer.handleRequest (/Users/erichowey/coding/ehdev-v3/node_modules/next/dist/server/base-server.js:319:20) {
  code: 'ERR_REQUIRE_ESM',
  page: '/studio/[[...index]]'

@ehowey
Copy link

ehowey commented Nov 10, 2022

After doing some more digging this is somewhat of a known issue when combining the markdown editor and NextJS: uiwjs/react-md-editor#52 (comment)

@fabianlee1211
Copy link

fabianlee1211 commented Jan 28, 2023

I hacked around it by duplicating the plugin setup to my Next.js app. Similar to what the Sanity blog template did.

Then move the CSS import to your _app.js and remove the one in the plugin. If you run into any underlying libraries using any browser APIs like react-simplemde-editor which depends on codemirror uses navigator, simply turn the component to a dynamic client side import with Next.

const SimpleMdeReact = dynamic(() => import('react-simplemde-editor'), {
  ssr: false,
  loading: () => <Spinner />,
});

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

No branches or pull requests

5 participants