Bug description,我正在使用一个名为react的库,它来自于NextJS中的brainhubeu。即使当我使用带有ssr:false的动态导入时,构建UI看起来也很奇怪,但是dev UI是非常好的。
dev UI -

我也在Codesandbox中重新创建了它(这是因为dev环境正在运行npm run dev)- https://codesandbox.io/embed/suspicious-volhard-460q8?fontsize=14&hidenavigation=1&theme=dark
但是,当我构建它,然后使用npm run build && npm run start运行构建时-

在密码箱里重现这一切-
期望的行为 UI应该与npm中看到的行为相同。
问题
我的尝试
谢谢你帮忙。
发布于 2020-12-01 04:29:48
我解决了这个问题。在我的例子中,这是由于我如何设置(dev)和next build & next start之间的差异。注意一些事情来解决这个问题-
现在让我们快速看看你如何解决这个问题-
// postcss.config.js
const purgecss = [
"@fullhuman/postcss-purgecss",
{
content: [
"./node_modules/@brainhubeu/react-carousel/lib/style.css",
"./node_modules/@brainhubeu/react-carousel/lib/style.css.map",
"./node_modules/react-toastify/dist/*.css",
"./components/**/*.js",
"./pages/**/*.js",
],
defaultExtractor: (content) => {
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [];
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || [];
return broadMatches.concat(innerMatches);
},
},
];
module.exports = {
plugins: [
"postcss-import",
"tailwindcss",
"autoprefixer",
...(process.env.NODE_ENV === "production" ? [purgecss] : []),
],
};不过,我还是建议你走第一条路,把你的代码从旧的回购系统复制到新的,使用SSR:false来使用客户端的库,这些库讨厌SSR,你应该做得很好。
如果你需要帮助的话,你可以联系我的推特@韧皮年。
https://stackoverflow.com/questions/62858813
复制相似问题