Skip to content

Commit

Permalink
添加对package引用
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteSevs committed Jul 14, 2024
1 parent e3ad72f commit cef0269
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
13 changes: 13 additions & 0 deletions packages/demo-vite-typescript/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
18 changes: 16 additions & 2 deletions packages/demo-vue-vite-typescript/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit cef0269

Please sign in to comment.