From cef026947c5d272c22d7af8529204ea5d2f357ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=9F=92?= <893177236@qq.com> Date: Sun, 14 Jul 2024 23:23:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9package=E5=BC=95?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/demo-vite-typescript/vite.config.ts | 13 +++++++++++++ .../demo-vue-vite-typescript/vite.config.ts | 18 ++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/demo-vite-typescript/vite.config.ts b/packages/demo-vite-typescript/vite.config.ts index d233e8d63..a27b9d80c 100644 --- a/packages/demo-vite-typescript/vite.config.ts +++ b/packages/demo-vite-typescript/vite.config.ts @@ -2,6 +2,19 @@ import { defineConfig } from "vite"; import monkey, { cdn, util } from "vite-plugin-monkey"; import { ViteUtils, GetLib } from "./vite.utils"; +const pkg = require("./package.json") as { + name: string; + version: string; + scripts: { + [key: string]: string; + }; + dependencies: { + [key: string]: string; + }; + devDependencies: { + [key: string]: string; + }; +}; const SCRIPT_NAME = "Demo Script Name"; const Utils = new ViteUtils(__dirname); let FILE_NAME = SCRIPT_NAME + ".user.js"; diff --git a/packages/demo-vue-vite-typescript/vite.config.ts b/packages/demo-vue-vite-typescript/vite.config.ts index 0c827a764..98251a0fb 100644 --- a/packages/demo-vue-vite-typescript/vite.config.ts +++ b/packages/demo-vue-vite-typescript/vite.config.ts @@ -8,6 +8,19 @@ import AutoImport from "unplugin-auto-import/vite"; import Components from "unplugin-vue-components/vite"; import { ElementPlusResolver } from "unplugin-vue-components/resolvers"; +const pkg = require("./package.json") as { + name: string; + version: string; + scripts: { + [key: string]: string; + }; + dependencies: { + [key: string]: string; + }; + devDependencies: { + [key: string]: string; + }; +}; /* 脚本名 */ const SCRIPT_NAME = "Demo Script Name"; const Utils = new ViteUtils(__dirname); @@ -105,8 +118,9 @@ export default defineConfig({ // 引用外部资源 resource: { - ElementPlusResourceCSS: - "https://fastly.jsdelivr.net/npm/element-plus@2.7.5/dist/index.min.css", + ElementPlusResourceCSS: `https://fastly.jsdelivr.net/npm/element-plus@${pkg.devDependencies[ + "element-plus" + ].replace(/^\^/, "")}/dist/index.min.css`, }, }, clientAlias: "ViteGM",