npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tomjs/vite-plugin-monaco-editor

v1.1.1

Published

vite plugin for monaco-editor, inject scripts for index.html

Downloads

217

Readme

@tomjs/vite-plugin-monaco-editor

npm node-current (scoped) NPM Docs

English | 中文

vite monaco-editor插件,为index.html注入脚本

特性

  • vite serve 时使用 node_modules 目录下的库
  • vite build 时可选使用 本地CDN

安装

# pnpm
pnpm add monaco-editor
pnpm add @tomjs/vite-plugin-monaco-editor -D

# yarn
yarn add monaco-editor
yarn add @tomjs/vite-plugin-monaco-editor -D

# npm
npm i monaco-editor --save
npm i @tomjs/vite-plugin-monaco-editor --save-dev

使用说明

以 vue/react 项目为例

vue示例

import { defineConfig } from 'vite';
import monaco from '@tomjs/vite-plugin-monaco-editor';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
  plugins: [
    vue(),
    // 默认使用 cdn
    monaco(),
  ],
});

react示例

import { defineConfig } from 'vite';
import monaco from '@tomjs/vite-plugin-monaco-editor';
import react from '@vitejs/plugin-react-swc';

export default defineConfig({
  // 使用本地的monaco-editor,从 node_modules 复制到 dist 目录
  plugins: [react(), monaco({ local: true })],
});

文档

参数

| 参数 | 类型 | 默认 | 描述 | | --- | --- | --- | --- | | type | 'npmmirror' \| 'unpkg' \| 'jsdelivr' \| 'custom' | 'unpkg' | CDN 源类型,参数 name/version/file 取自模块配置。 当操作系统语言为 zh_CN 时,默认值为 npmmirror ,否则为 jsdelivr。 | | url | string | '' | 自定义 URL(与 type 一起使用) | | local | boolean | NpmLocal | false | 本地模式或本地模式的更多配置 | | serve | ServerConfig | { base: './'} | vite命令为serve时的配置 |

CDN type:

  • npmmirror: url 默认为 https://registry.npmmirror.com/monaco-editor/{version}/files
  • jsdelivr: url 默认为 https://cdn.jsdelivr.net/npm/monaco-editor@{version}
  • unpkg: url 默认为 https://unpkg.com/monaco-editor@{version}
  • custom: 可以自定义 url

NpmLocal

本地配置。

| 参数 | 类型 | 默认 | 描述 | | ------ | --------- | ------------------------------- | ----------------------------------------- | | base | string | '/' | 与 Vite 的 base 选项相同 | | outDir | string | 'dist' | 本地输出目录,默认为Vite的 build.outDir | | path | string | 'npm/monaco-editor@{version}' | 本地输出路径,模块 URL 也将替换为该路径 | | copy | boolean | true | 是否将 monaco-editor 复制到输出目录 |

ServerConfig

vite命令为 serve 时的配置

| 参数 | 类型 | 默认 | 描述 | | ---- | -------- | ------ | ----------------------- | | base | string | './' | node_modules 的相对路径 |

开发

  • 开发环境

    • git
    • node>=18
    • pnpm>=8
  • 首次使用,需要安装依赖,执行如下命令

# 安装依赖
pnpm i
# 编译库
pnpm build
  • 调试 vue 项目,执行如下命令
cd examples/vue
pnpm build
pnpm preview
  • 调试 react 项目,执行如下命令
cd examples/react
pnpm build
pnpm preview