小编Yoi*_*aka的帖子

Monaco Editor 在使用 Webpack 的情况下不会加载代码图标

在使用 Webpack 的情况下尝试使用Monaco Editor时,不会加载代码图标。我使用了 monaco-editor-webpack-plugin 并按照说明进行操作,但目前我的测试页面中的 Monaco Editor 实例上看不到任何图标。

在此输入图像描述

我是否忘记加载代码了?

您可以通过以下方式重现此问题:https ://github.com/yoichiro/monaco-editor-test/tree/main

索引.html

<!doctype html>
<html lang="en">
<head>
  <style>
    .source-editor {
                width: 640px;
                height: 320px;
        }
  </style>
</head>
<body>
  <div class="source-editor"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

索引.ts

import * as monaco from 'monaco-editor';

window.addEventListener('load', () => {
        monaco.editor.create(document.querySelector('.source-editor'));
});
Run Code Online (Sandbox Code Playgroud)

webpack.config.js

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const MonacoEditorWebpackPlugin = require('monaco-editor-webpack-plugin');

module.exports = {
  mode: 'development',
  entry: './src/index.ts',
  output: {
    path: path.resolve(__dirname, 'build'), …
Run Code Online (Sandbox Code Playgroud)

javascript webpack monaco-editor

3
推荐指数
1
解决办法
3365
查看次数

标签 统计

javascript ×1

monaco-editor ×1

webpack ×1