{"id":18822999,"url":"https://github.com/tomjs/vite-plugin-monaco-editor","last_synced_at":"2025-04-14T01:24:45.152Z","repository":{"id":214069497,"uuid":"735644289","full_name":"tomjs/vite-plugin-monaco-editor","owner":"tomjs","description":"vite plugin for monaco-editor, inject scripts for index.html","archived":false,"fork":false,"pushed_at":"2024-07-01T16:15:41.000Z","size":121,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-27T15:22:08.723Z","etag":null,"topics":["cdn","local","monaco","monaco-editor","plugin","vite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-25T16:56:42.000Z","updated_at":"2024-07-01T16:15:40.000Z","dependencies_parsed_at":"2023-12-25T17:24:38.979Z","dependency_job_id":"c141db8a-1d50-4763-bca2-3364f7c7eef0","html_url":"https://github.com/tomjs/vite-plugin-monaco-editor","commit_stats":null,"previous_names":["tomjs/vite-plugin-monaco-editor"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomjs%2Fvite-plugin-monaco-editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomjs%2Fvite-plugin-monaco-editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomjs%2Fvite-plugin-monaco-editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomjs%2Fvite-plugin-monaco-editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomjs","download_url":"https://codeload.github.com/tomjs/vite-plugin-monaco-editor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248805765,"owners_count":21164385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdn","local","monaco","monaco-editor","plugin","vite"],"created_at":"2024-11-08T00:52:20.506Z","updated_at":"2025-04-14T01:24:45.130Z","avatar_url":"https://github.com/tomjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @tomjs/vite-plugin-monaco-editor\n\n[![npm](https://img.shields.io/npm/v/@tomjs/vite-plugin-monaco-editor)](https://www.npmjs.com/package/@tomjs/vite-plugin-monaco-editor) ![node-current (scoped)](https://img.shields.io/node/v/@tomjs/vite-plugin-monaco-editor) ![NPM](https://img.shields.io/npm/l/@tomjs/vite-plugin-monaco-editor) [![Docs](https://img.shields.io/badge/API-unpkg-orange)](https://www.unpkg.com/browse/@tomjs/vite-plugin-monaco-editor/dist/index.d.ts)\n\n**English** | [中文](./README.zh_CN.md)\n\n\u003e [vite](https://vitejs.dev) plugin for [monaco-editor](https://github.com/microsoft/monaco-editor), inject scripts for index.html\n\n## Features\n\n- Use libraries in the `node_modules` directory when `vite serve`\n- Optional use of `local` or `CDN` when `vite build`\n\n## Install\n\n```bash\n# pnpm\npnpm add monaco-editor\npnpm add @tomjs/vite-plugin-monaco-editor -D\n\n# yarn\nyarn add monaco-editor\nyarn add @tomjs/vite-plugin-monaco-editor -D\n\n# npm\nnpm i monaco-editor --save\nnpm i @tomjs/vite-plugin-monaco-editor --save-dev\n```\n\n## Usage\n\nTaking Vue/React projects as examples:\n\n### Vue Example\n\n```js\nimport { defineConfig } from 'vite';\nimport monaco from '@tomjs/vite-plugin-monaco-editor';\nimport vue from '@vitejs/plugin-vue';\n\nexport default defineConfig({\n  plugins: [\n    vue(),\n    // use cdn by default\n    monaco(),\n  ],\n});\n```\n\n### React Example\n\n```js\nimport { defineConfig } from 'vite';\nimport monaco from '@tomjs/vite-plugin-monaco-editor';\nimport react from '@vitejs/plugin-react-swc';\n\nexport default defineConfig({\n  // use the local monaco-editor, copy from node_modules to the dist directory\n  plugins: [react(), monaco({ local: true })],\n});\n```\n\n## Documentation\n\n- [index.d.ts](https://www.unpkg.com/browse/@tomjs/vite-plugin-monaco-editor/dist/index.d.ts) provided by [unpkg.com](https://www.unpkg.com).\n\n## Parameters\n\n| Parameter | Type | Default | Description |\n| --- | --- | --- | --- |\n| type | `'npmmirror' \\| 'unpkg' \\| 'jsdelivr' \\| 'custom'` | `'unpkg'` | `CDN` source type, parameters `version` are taken from the modules configuration. When the OS language is `zh_CN` , the default value is `npmmirror`, otherwise it is `jsdelivr`. |\n| url | `string` | '' | Custom URL (used with `type` ) |\n| local | `boolean` \\| [NpmLocal](#NpmLocal) | `false` | Local mode or more configurations for local mode |\n| serve | [ServerConfig](#ServerConfig) | `{ base: './'}` | Configuration when vite command is serve |\n\nCDN type:\n\n- npmmirror: base will be set to https://registry.npmmirror.com/monaco-editor/{version}/files\n- jsdelivr: base will be set to https://cdn.jsdelivr.net/npm/monaco-editor@{version}\n- unpkg: base will be set to https://unpkg.com/monaco-editor@{version}\n- custom: custom url can be defined\n\n### NpmLocal\n\nLocal configuration.\n\n| Parameter | Type | Default | Description |\n| --- | --- | --- | --- |\n| base | `string` | `'/'` | Same as Vite's `base` option |\n| outDir | `string` | `'dist'` | Local output directory, defaults to Vite's `build.outDir` |\n| path | `string` | `'npm/monaco-editor@{version}'` | Local output path, module URLs will also be replaced with this path |\n| copy | `boolean` | `true` | Whether to copy monaco-editor to output directory |\n\n### ServerConfig\n\nConfiguration when vite command is serve.\n\n| Parameter | Type     | Default | Description                   |\n| --------- | -------- | ------- | ----------------------------- |\n| base      | `string` | `'./'`  | Relative path to node_modules |\n\n## Development\n\n- Development requirements:\n\n  - git\n  - node\u003e=18\n  - pnpm\u003e=8\n\n- For first-time use, install dependencies by running the following commands:\n\n```bash\n# Install dependencies\npnpm i\n# build library\npnpm build\n```\n\n- To debug the `vue` project, execute the following commands:\n\n```bash\ncd examples/vue\npnpm build\npnpm preview\n```\n\n- To debug the `react` project, execute the following commands:\n\n```bash\ncd examples/react\npnpm build\npnpm preview\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomjs%2Fvite-plugin-monaco-editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomjs%2Fvite-plugin-monaco-editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomjs%2Fvite-plugin-monaco-editor/lists"}