带有 nextjs 的摩纳哥编辑器 [英] Monaco editor with nextjs
本文介绍了带有 nextjs 的摩纳哥编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用带有 next js 的 monaco 编辑器时出现此错误.有人解决了吗?
Getting this error when using monaco editor with next js. Have anyone resolved this?
Failed to compile
./node_modules/monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.css
Global CSS cannot be imported from within node_modules.
Read more: https://err.sh/next.js/css-npm
Location: node_modules/monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js```
推荐答案
添加这个 webpack 配置为我修复了它
Add this webpack config fixed it for me
const withCSS = require('@zeit/next-css');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
module.exports = withCSS({
webpack(config, options) {
config.plugins.push(new MonacoWebpackPlugin());
return config;
},
cssLoaderOptions: { url: false }
})
这篇关于带有 nextjs 的摩纳哥编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文