Vite Plugin CDN Import 使用教程
2024-08-17 17:18:51作者:殷蕙予
1. 项目的目录结构及介绍
Vite Plugin CDN Import 项目的目录结构如下:
vite-plugin-cdn-import/
├── docs/
├── examples/
├── src/
├── __tests__/
├── .gitignore
├── .yarnrc.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── eslint.config.js
├── package.json
├── tsconfig.json
├── tsup.config.ts
├── yarn.lock
目录介绍:
docs/: 存放项目的文档文件。examples/: 存放示例代码。src/: 存放源代码文件。__tests__/: 存放测试文件。.gitignore: Git 忽略文件配置。.yarnrc.yml: Yarn 配置文件。CHANGELOG.md: 项目更新日志。LICENSE: 项目许可证。README.md: 项目说明文档。eslint.config.js: ESLint 配置文件。package.json: 项目依赖和脚本配置。tsconfig.json: TypeScript 配置文件。tsup.config.ts: Tsup 配置文件。yarn.lock: Yarn 锁定文件。
2. 项目的启动文件介绍
项目的启动文件主要是 src/index.ts,该文件是插件的入口点,负责导出插件的主要功能。
// src/index.ts
import { Plugin } from 'vite';
import { createFilter } from '@rollup/pluginutils';
import { getRemoteModuleUrl } from './utils';
export default function cdnImport(options: {
modules: Array<{
name: string;
var: string;
path: string;
version?: string;
css?: string;
}>;
}): Plugin {
const filter = createFilter(options.include, options.exclude);
return {
name: 'vite-plugin-cdn-import',
transform(code, id) {
if (!filter(id)) return null;
// 处理代码中的模块导入
},
};
}
3. 项目的配置文件介绍
项目的配置文件主要是 vite.config.ts,该文件用于配置 Vite 项目。
// vite.config.ts
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { autoComplete, importToCDN } from 'vite-plugin-cdn-import';
export default defineConfig({
plugins: [
vue(),
importToCDN({
prodUrl: 'https://unpkg.com/[name]@[version]/[path]',
modules: [
autoComplete('vue'),
autoComplete('axios'),
{
name: 'element-plus',
var: 'ElementPlus',
version: '2.2.17',
path: 'dist/index.full.js',
css: 'dist/index.css',
},
{
name: 'vue-demi',
var: 'VueDemi',
version: '0.13.11',
path: 'lib/index.iife.js',
},
{
name: '@element-plus/icons-vue',
var: 'ElementPlusIconsVue',
version: '2.0.9',
path: 'dist/index.iife.min.js',
},
{
name: 'bootstrap',
var: 'bootStrap',
version: '5.1.3',
path: 'dist/js/bootstrap.js',
css: 'dist/css/bootstrap.min.css',
},
],
}),
],
});
配置文件介绍:
plugins: 配置 Vite 插件,包括vue和vite-plugin-cdn-import。importToCDN: 配置 CDN 引入的模块,包括模块名称、变量名、版本号、路径和 CSS 文件路径。
以上是 Vite Plugin CDN Import 项目的目录
登录后查看全文
热门项目推荐
Kimi-K2.5Kimi K2.5 是一款开源的原生多模态智能体模型,它在 Kimi-K2-Base 的基础上,通过对约 15 万亿混合视觉和文本 tokens 进行持续预训练构建而成。该模型将视觉与语言理解、高级智能体能力、即时模式与思考模式,以及对话式与智能体范式无缝融合。Python00- QQwen3-Coder-Next2026年2月4日,正式发布的Qwen3-Coder-Next,一款专为编码智能体和本地开发场景设计的开源语言模型。Python00
xw-cli实现国产算力大模型零门槛部署,一键跑通 Qwen、GLM-4.7、Minimax-2.1、DeepSeek-OCR 等模型Go06
PaddleOCR-VL-1.5PaddleOCR-VL-1.5 是 PaddleOCR-VL 的新一代进阶模型,在 OmniDocBench v1.5 上实现了 94.5% 的全新 state-of-the-art 准确率。 为了严格评估模型在真实物理畸变下的鲁棒性——包括扫描伪影、倾斜、扭曲、屏幕拍摄和光照变化——我们提出了 Real5-OmniDocBench 基准测试集。实验结果表明,该增强模型在新构建的基准测试集上达到了 SOTA 性能。此外,我们通过整合印章识别和文本检测识别(text spotting)任务扩展了模型的能力,同时保持 0.9B 的超紧凑 VLM 规模,具备高效率特性。Python00
KuiklyUI基于KMP技术的高性能、全平台开发框架,具备统一代码库、极致易用性和动态灵活性。 Provide a high-performance, full-platform development framework with unified codebase, ultimate ease of use, and dynamic flexibility. 注意:本仓库为Github仓库镜像,PR或Issue请移步至Github发起,感谢支持!Kotlin08
VLOOKVLOOK™ 是优雅好用的 Typora/Markdown 主题包和增强插件。 VLOOK™ is an elegant and practical THEME PACKAGE × ENHANCEMENT PLUGIN for Typora/Markdown.Less00
项目优选
收起
deepin linux kernel
C
27
11
OpenHarmony documentation | OpenHarmony开发者文档
Dockerfile
538
3.76 K
暂无简介
Dart
774
192
Ascend Extension for PyTorch
Python
343
406
🎉 (RuoYi)官方仓库 基于SpringBoot,Spring Security,JWT,Vue3 & Vite、Element Plus 的前后端分离权限管理系统
Vue
1.34 K
756
🍒 Cherry Studio 是一款支持多个 LLM 提供商的桌面客户端
TypeScript
1.07 K
97
React Native鸿蒙化仓库
JavaScript
303
356
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
337
180
AscendNPU-IR
C++
86
142
openJiuwen agent-studio提供零码、低码可视化开发和工作流编排,模型、知识库、插件等各资源管理能力
TSX
987
249