partridgejiang / Kekule.js

A Javascript cheminformatics toolkit.
http://partridgejiang.github.io/Kekule.js
MIT License
248 stars 61 forks source link

Help using Kekule in Next.js project #262

Open LeandroHornos opened 2 years ago

LeandroHornos commented 2 years ago

I've been playing with Kekule composer widget in React using this workaround to make it work with webpack when using create-react-app

Now I'm trying to use the component in a Next.js app created with create-next-app but I'm having this issue when trying to import kekule from the npm package. Failed to compile ./node_modules/kekule/dist/themes/default/kekule.css Global CSS cannot be imported from within node_modules. Read more: https://nextjs.org/docs/messages/css-npm Location: node_modules\kekule\dist\kekule.webpack.prod.js

Any help would be greatly appreciated, thanks!!!

partridgejiang commented 2 years ago

Not tested in the Next environment but I guess the following approach may be a possible workaround. Please remove the CSS importing line in kekule.webpack.prod.js (require("./themes/default/kekule.css");), and require this CSS file in your own _app.js instead. Have a try of that?

LeandroHornos commented 2 years ago

It worked! Thank you very much!

Benjaki2 commented 2 years ago

@LeandroHornos what did your Webpack override(next.config.js) look like? I'm having trouble integrating the react-app-rewired solution to nextjs. Thanks!