带有nextjs的摩纳哥编辑器

问题描述 投票:0回答:1

在下一个js中使用monaco编辑器时出现此错误。有人解决了吗?

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```
reactjs next.js monaco-editor
1个回答
1
投票

添加此webpack配置为我修复了它

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 }
})

© www.soinside.com 2019 - 2024. All rights reserved.