@vearvip/vite-plugin-cdn-import 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 - MMF-FE
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # Import modules from CDN with vite plugin
2
+
3
+ English | [简体中文](README.zh-CN.md)
4
+
5
+ [![GitHub tag](https://img.shields.io/github/tag/MMF-FE/vite-plugin-cdn-import.svg)](https://github.com/MMF-FE/vite-plugin-cdn-import/releases)
6
+ [![License](https://img.shields.io/github/license/SafdarJamal/vite-template-react)](https://github.com/MMF-FE/vite-plugin-cdn-import/blob/master/LICENSE)
7
+
8
+ Allows you to specify modules to be introduced in a production environment using a CDN.
9
+
10
+ This can reduce build time and improve page load speed in production environments.
11
+
12
+ ## Installation
13
+
14
+ Install the plugin with npm:
15
+
16
+ ```
17
+ npm install vite-plugin-cdn-import --save-dev
18
+ ```
19
+
20
+ or yarn
21
+
22
+ ```
23
+ yarn add vite-plugin-cdn-import -D
24
+ ```
25
+
26
+ ## Basic Usage
27
+
28
+ Add it to vite.config.js
29
+
30
+ ```js
31
+ // vite.config.js
32
+ import cdn from 'vite-plugin-cdn-import'
33
+
34
+ export default {
35
+ plugins: [
36
+ cdn({
37
+ modules: [
38
+ {
39
+ name: 'react',
40
+ var: 'React',
41
+ path: `umd/react.production.min.js`,
42
+ },
43
+ {
44
+ name: 'react-dom',
45
+ var: 'ReactDOM',
46
+ path: `umd/react-dom.production.min.js`,
47
+ },
48
+ ],
49
+ }),
50
+ ],
51
+ }
52
+ ```
53
+
54
+ ### Use preset
55
+
56
+ ```js
57
+ // vite.config.js
58
+ import cdn from 'vite-plugin-cdn-import'
59
+
60
+ export default {
61
+ plugins: [
62
+ cdn({
63
+ modules: ['react', 'react-dom'],
64
+ }),
65
+ ],
66
+ }
67
+ ```
68
+
69
+ ### Preset packages
70
+
71
+ - react
72
+ - react-dom
73
+ - react-router-dom
74
+ - antd
75
+ - vue
76
+ - vue2
77
+ - vue-router
78
+ - vue-router@3
79
+ - moment
80
+ - dayjs
81
+ - axios
82
+ - lodash
83
+
84
+ ## Options
85
+
86
+
87
+ ### prodUrl
88
+ Global prodUrl attribute, template url that generates CND file path.
89
+ - REF: [prodUrl](https://github.com/shirotech/webpack-cdn-plugin?tab=readme-ov-file#produrlstring--unpkgcomnameversionpath)
90
+ - Type
91
+ ```ts
92
+ {
93
+ prodUrl?: string
94
+ }
95
+ ```
96
+ - Default: <https://cdn.jsdelivr.net/npm/{name}@{version}/{path}>
97
+
98
+ ### modules
99
+ external config
100
+ - Type
101
+ ```ts
102
+ type GetModuleFunc = (prodUrl: string) => Module
103
+ {
104
+ modules: (Module | Module[] | GetModuleFunc | GetModuleFunc[])[]
105
+ }
106
+ ```
107
+
108
+ ### enableInDevMode
109
+ Enabled in dev mode
110
+ - Type: `boolean`
111
+ - Default:`false`
112
+
113
+ > Please ensure process.env.NODE_ENV === 'development' when you use vite2, vite3.
114
+
115
+ ### generateScriptTag
116
+ Custom generated script tags
117
+ - Type
118
+ ```ts
119
+ generateScriptTag?: (
120
+ name: string,
121
+ scriptUrl: string,
122
+ ) => Omit<HtmlTagDescriptor, 'tag' | 'children'>
123
+ ```
124
+
125
+ ### generateCssLinkTag
126
+ Customize generated css link tags
127
+
128
+ - Type
129
+ ```ts
130
+ generateCssLinkTag?: (
131
+ name: string,
132
+ cssUrl: string,
133
+ ) => Omit<HtmlTagDescriptor, 'tag' | 'children'>
134
+ ```
135
+
136
+ ### Module
137
+
138
+ | Name | Description | Type |
139
+ | ---- | --------------------------------------------- | ----------------- |
140
+ | name | package name | string |
141
+ | alias | Alias ​​of name, for example "react-dom/client" is an alias of "react-dom" | string[] |
142
+ | var | Variables assigned globally to the module| string |
143
+ | path | Specify the load path on the CDN | string / string[] |
144
+ | css | Multiple style sheets can be loaded from CDN addresses | string / string[] |
145
+ | prodUrl | Override global prodUrl | string / string[] |
146
+
147
+
148
+ ## Other CDN pordUrl
149
+
150
+ | Name | pordUrl |
151
+ | ----- | -------------------------------------------------------- |
152
+ | unpkg | //unpkg.com/{name}@{version}/{path} |
153
+ | cdnjs | //cdnjs.cloudflare.com/ajax/libs/{name}/{version}/{path} |
154
+
155
+ ## Ressources
156
+
157
+ - [webpack-cdn-plugin](https://github.com/shirotech/webpack-cdn-plugin)
158
+ - [rollup-plugin-external-globals](https://github.com/eight04/rollup-plugin-external-globals)
159
+ - [vite-plugin-externals](https://github.com/crcong/vite-plugin-externals)
@@ -0,0 +1,155 @@
1
+ # 从 CDN 加载 modules 的 vite 插件
2
+
3
+ [English](README.md) | 简体中文
4
+
5
+ [![GitHub tag](https://img.shields.io/github/tag/MMF-FE/vite-plugin-cdn-import.svg)](https://github.com/MMF-FE/vite-plugin-cdn-import/releases)
6
+ [![License](https://img.shields.io/github/license/SafdarJamal/vite-template-react)](https://github.com/MMF-FE/vite-plugin-cdn-import/blob/master/LICENSE)
7
+
8
+ 允许指定 modules 在生产环境中使用 CDN 引入。
9
+
10
+ 这可以减少构建时间,并且提高生产环境中页面加载速度。
11
+
12
+ ## 安装
13
+
14
+ 下载 npm 插件
15
+
16
+ ```bash
17
+ npm install vite-plugin-cdn-import --save-dev
18
+ ```
19
+
20
+ or yarn
21
+
22
+ ```bash
23
+ yarn add vite-plugin-cdn-import -D
24
+ ```
25
+
26
+ ## 基本用法
27
+
28
+ ```js
29
+ // vite.config.js
30
+ import cdn from 'vite-plugin-cdn-import'
31
+
32
+ export default {
33
+ plugins: [
34
+ cdn({
35
+ modules: [
36
+ {
37
+ name: 'react',
38
+ var: 'React',
39
+ path: `umd/react.production.min.js`,
40
+ },
41
+ {
42
+ name: 'react-dom',
43
+ var: 'ReactDOM',
44
+ path: `umd/react-dom.production.min.js`,
45
+ },
46
+ ],
47
+ }),
48
+ ],
49
+ }
50
+ ```
51
+
52
+ ### 使用预设
53
+
54
+ ```js
55
+ // vite.config.js
56
+ import cdn from 'vite-plugin-cdn-import'
57
+
58
+ export default {
59
+ plugins: [
60
+ cdn({
61
+ modules: ['react', 'react-dom'],
62
+ }),
63
+ ],
64
+ }
65
+ ```
66
+
67
+ ### 预设的 npm 包
68
+
69
+ - react
70
+ - react-dom
71
+ - react-router-dom
72
+ - antd
73
+ - vue
74
+ - vue2
75
+ - vue-router
76
+ - vue-router@3
77
+ - moment
78
+ - dayjs
79
+ - axios
80
+ - lodash
81
+
82
+
83
+ ## 参数
84
+
85
+ ### prodUrl
86
+ 全局 prodUrl 属性,生成 CND 文件路径的模板 url.
87
+ - REF: [prodUrl](https://github.com/shirotech/webpack-cdn-plugin?tab=readme-ov-file#produrlstring--unpkgcomnameversionpath)
88
+ - 类型
89
+ ```ts
90
+ {
91
+ prodUrl?: string
92
+ }
93
+ ```
94
+ - 默认值: <https://cdn.jsdelivr.net/npm/{name}@{version}/{path}>
95
+
96
+ ### modules
97
+ external 模块配置
98
+ - 类型
99
+ ```ts
100
+ type GetModuleFunc = (prodUrl: string) => Module
101
+ {
102
+ modules: (Module | Module[] | GetModuleFunc | GetModuleFunc[])[]
103
+ }
104
+ ```
105
+
106
+ ### enableInDevMode
107
+ 是否在开发模式中启用
108
+ - 类型: `boolean`
109
+ - 默认值:`false`
110
+
111
+ > vite2, vite3 请确保开发模式 process.env.NODE_ENV === 'development'
112
+
113
+ ### generateScriptTag
114
+ 自定义生成的 script 标签
115
+ - 类型
116
+ ```ts
117
+ generateScriptTag?: (
118
+ name: string,
119
+ scriptUrl: string,
120
+ ) => Omit<HtmlTagDescriptor, 'tag' | 'children'>
121
+ ```
122
+
123
+ ### generateCssLinkTag
124
+ 自定义生成 css link 标签
125
+ - 类型
126
+ ```ts
127
+ generateCssLinkTag?: (
128
+ name: string,
129
+ cssUrl: string,
130
+ ) => Omit<HtmlTagDescriptor, 'tag' | 'children'>
131
+ ```
132
+
133
+ ### Module 配置
134
+
135
+ | Name | Description | Type |
136
+ | ---- | --------------------------------------------- | ----------------- |
137
+ | name | 需要 CDN 加速的包名称 | string |
138
+ | alias | 名称的别名,例如“react-dom/client”是“react-dom”的别名 | string[] |
139
+ | var | 全局分配给模块的变量 | string |
140
+ | path | 指定 CDN 上的加载路径 | string / string[] |
141
+ | css | 可以指定从 CDN 地址上加载多个样式表 | string / string[] |
142
+ | prodUrl | 覆盖全局的 prodUrl | string / string[] |
143
+
144
+ ## 其他的 CDN pordUrl 地址
145
+
146
+ | Name | pordUrl |
147
+ | ----- | -------------------------------------------------------- |
148
+ | unpkg | //unpkg.com/{name}@{version}/{path} |
149
+ | cdnjs | //cdnjs.cloudflare.com/ajax/libs/{name}/{version}/{path} |
150
+
151
+ ## 资源
152
+
153
+ - [webpack-cdn-plugin](https://github.com/shirotech/webpack-cdn-plugin)
154
+ - [rollup-plugin-external-globals](https://github.com/eight04/rollup-plugin-external-globals)
155
+ - [vite-plugin-externals](https://github.com/crcong/vite-plugin-externals)
package/dist/index.cjs ADDED
@@ -0,0 +1,379 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+
47
+ // src/index.ts
48
+ var src_exports = {};
49
+ __export(src_exports, {
50
+ Plugin: () => PluginImportToCDN,
51
+ autoComplete: () => autoComplete2,
52
+ default: () => src_default
53
+ });
54
+ module.exports = __toCommonJS(src_exports);
55
+ var import_rollup_plugin_external_globals = __toESM(require("rollup-plugin-external-globals"), 1);
56
+ var import_vite_plugin_externals = require("vite-plugin-externals");
57
+ var import_fs = __toESM(require("fs"), 1);
58
+ var import_path = __toESM(require("path"), 1);
59
+
60
+ // src/autoComplete.ts
61
+ var isDev = process.env.NODE_ENV === "development";
62
+ var modulesConfig = {
63
+ react: {
64
+ var: "React",
65
+ jsdeliver: {
66
+ path: isDev ? "umd/react.development.js" : "umd/react.production.min.js"
67
+ },
68
+ bootCdn: {
69
+ path: isDev ? "umd/react.development.js" : "umd/react.production.min.js"
70
+ }
71
+ },
72
+ "react-dom": {
73
+ var: "ReactDOM",
74
+ alias: ["react-dom/client"],
75
+ jsdeliver: {
76
+ path: isDev ? "umd/react-dom.development.js" : "umd/react-dom.production.min.js"
77
+ },
78
+ bootCdn: {
79
+ path: isDev ? "umd/react-dom.development.js" : "umd/react-dom.production.min.js"
80
+ }
81
+ },
82
+ "react-router-dom": {
83
+ var: "ReactRouterDOM",
84
+ jsdeliver: {
85
+ path: "dist/umd/react-router-dom.production.min.js"
86
+ },
87
+ bootCdn: {
88
+ path: "umd/react-router-dom.production.min.js"
89
+ }
90
+ },
91
+ antd: {
92
+ var: "antd",
93
+ jsdeliver: {
94
+ path: "dist/antd.min.js",
95
+ css: "dist/reset.min.css"
96
+ },
97
+ bootCdn: {
98
+ path: "antd.min.js",
99
+ css: "reset.min.css"
100
+ }
101
+ },
102
+ vue: {
103
+ var: "Vue",
104
+ jsdeliver: {
105
+ path: isDev ? "dist/vue.runtime.global.js" : "dist/vue.runtime.global.prod.js"
106
+ },
107
+ bootCdn: {
108
+ path: isDev ? "vue.runtime.global.js" : "vue.runtime.global.prod.js"
109
+ }
110
+ },
111
+ "vue-router": {
112
+ var: "VueRouter",
113
+ jsdeliver: {
114
+ path: "dist/vue-router.global.min.js"
115
+ },
116
+ bootCdn: {
117
+ path: "vue-router.global.min.js"
118
+ }
119
+ },
120
+ "vue-router@3": {
121
+ var: "VueRouter",
122
+ jsdeliver: {
123
+ name: "vue-router",
124
+ path: "dist/vue-router.min.js"
125
+ },
126
+ bootCdn: {
127
+ name: "vue-router",
128
+ path: "vue-router.min.js"
129
+ }
130
+ },
131
+ vue2: {
132
+ var: "Vue",
133
+ jsdeliver: {
134
+ name: "vue",
135
+ path: isDev ? "dist/vue.runtime.js" : "dist/vue.runtime.min.js"
136
+ },
137
+ bootCdn: {
138
+ name: "vue",
139
+ path: isDev ? "vue.runtime.js" : "vue.runtime.min.js"
140
+ }
141
+ },
142
+ moment: {
143
+ var: "moment",
144
+ jsdeliver: {
145
+ path: "moment.min.js"
146
+ },
147
+ bootCdn: {
148
+ path: "moment.min.js"
149
+ }
150
+ },
151
+ dayjs: {
152
+ var: "dayjs",
153
+ jsdeliver: {
154
+ path: "dayjs.min.js"
155
+ },
156
+ bootCdn: {
157
+ path: "dayjs.min.js"
158
+ }
159
+ },
160
+ axios: {
161
+ var: "axios",
162
+ jsdeliver: {
163
+ path: "dist/axios.min.js"
164
+ },
165
+ bootCdn: {
166
+ path: "axios.min.js"
167
+ }
168
+ },
169
+ lodash: {
170
+ var: "_",
171
+ jsdeliver: {
172
+ path: "lodash.min.js"
173
+ },
174
+ bootCdn: {
175
+ path: "lodash.min.js"
176
+ }
177
+ }
178
+ };
179
+ function isJsdeliver(prodUrl) {
180
+ return prodUrl.includes("//cdn.jsdelivr.net");
181
+ }
182
+ function isUnpkg(prodUrl) {
183
+ return prodUrl.includes("//unpkg.com");
184
+ }
185
+ function isCdnjs(prodUrl) {
186
+ return prodUrl.includes("//cdnjs.cloudflare.com");
187
+ }
188
+ function isBootCdn(prodUrl) {
189
+ return prodUrl.includes("//cdn.bootcdn.net");
190
+ }
191
+ function genModuleByName(name) {
192
+ const config = modulesConfig[name];
193
+ if (!config) {
194
+ throw new Error(`The configuration of module ${name} does not exist `);
195
+ }
196
+ return (prodUrl) => {
197
+ if (isCdnjs(prodUrl)) {
198
+ throw new Error(
199
+ `The configuration of module ${name} in ${prodUrl} does not exist `
200
+ );
201
+ } else {
202
+ if (!(isJsdeliver(prodUrl) || isUnpkg(prodUrl)) || isBootCdn(prodUrl)) {
203
+ console.warn(
204
+ "Unknown CDN, please ensure that this CDN supports jsdelivr rules"
205
+ );
206
+ }
207
+ return __spreadValues({
208
+ name,
209
+ var: config.var,
210
+ alias: config.alias
211
+ }, isBootCdn(prodUrl) ? config.bootCdn : config.jsdeliver);
212
+ }
213
+ };
214
+ }
215
+ function autoComplete(name) {
216
+ if (Array.isArray(name)) {
217
+ return name.map(genModuleByName);
218
+ } else {
219
+ return genModuleByName(name);
220
+ }
221
+ }
222
+ var autoComplete_default = autoComplete;
223
+
224
+ // src/index.ts
225
+ var isDev2 = process.env.NODE_ENV === "development";
226
+ function getModuleVersion(name) {
227
+ const pwd = process.cwd();
228
+ const pkgFile = import_path.default.join(pwd, "node_modules", name, "package.json");
229
+ if (import_fs.default.existsSync(pkgFile)) {
230
+ const pkgJson = JSON.parse(import_fs.default.readFileSync(pkgFile, "utf8"));
231
+ return pkgJson.version;
232
+ }
233
+ return "";
234
+ }
235
+ function isFullPath(path2) {
236
+ return path2.startsWith("http:") || path2.startsWith("https:") || path2.startsWith("//") ? true : false;
237
+ }
238
+ function renderUrl(url, data) {
239
+ const { path: path2 } = data;
240
+ if (isFullPath(path2)) {
241
+ url = path2;
242
+ }
243
+ return url.replace(/\{name\}/g, data.name).replace(/\{version\}/g, data.version).replace(/\{path\}/g, path2);
244
+ }
245
+ function getModuleInfo(module2, prodUrl) {
246
+ prodUrl = module2.prodUrl || prodUrl;
247
+ let v = module2;
248
+ const version = getModuleVersion(v.name);
249
+ let pathList = [];
250
+ if (!Array.isArray(v.path)) {
251
+ pathList.push(v.path);
252
+ } else {
253
+ pathList = v.path;
254
+ }
255
+ const data = __spreadProps(__spreadValues({}, v), {
256
+ version
257
+ });
258
+ pathList = pathList.map((p) => {
259
+ if (!version && !isFullPath(p)) {
260
+ throw new Error(
261
+ `modules: ${data.name} package.json file does not exist`
262
+ );
263
+ }
264
+ return renderUrl(prodUrl, __spreadProps(__spreadValues({}, data), {
265
+ path: p
266
+ }));
267
+ });
268
+ let css = v.css || [];
269
+ if (!Array.isArray(css) && css) {
270
+ css = [css];
271
+ }
272
+ const cssList = !Array.isArray(css) ? [] : css.map(
273
+ (c) => renderUrl(prodUrl, __spreadProps(__spreadValues({}, data), {
274
+ path: c
275
+ }))
276
+ );
277
+ return __spreadProps(__spreadValues({}, v), {
278
+ version,
279
+ pathList,
280
+ cssList
281
+ });
282
+ }
283
+ function PluginImportToCDN(options) {
284
+ const {
285
+ modules = [],
286
+ prodUrl = "https://cdn.jsdelivr.net/npm/{name}@{version}/{path}",
287
+ enableInDevMode = false,
288
+ generateCssLinkTag,
289
+ generateScriptTag
290
+ } = options;
291
+ let isBuild = false;
292
+ const data = modules.map((_m) => {
293
+ const m = typeof _m === "string" ? autoComplete_default(_m) : _m;
294
+ const list = (Array.isArray(m) ? m : [m]).map(
295
+ (v) => typeof v === "function" ? v(prodUrl) : v
296
+ );
297
+ return list.map((v) => getModuleInfo(v, prodUrl));
298
+ }).flat();
299
+ const externalMap = {};
300
+ data.forEach((v) => {
301
+ externalMap[v.name] = v.var;
302
+ if (Array.isArray(v.alias)) {
303
+ v.alias.forEach((alias) => {
304
+ externalMap[alias] = v.var;
305
+ });
306
+ }
307
+ });
308
+ const plugins = [
309
+ {
310
+ name: "vite-plugin-cdn-import",
311
+ enforce: "pre",
312
+ config(_, { command }) {
313
+ isBuild = command === "build";
314
+ let userConfig = {
315
+ build: {
316
+ rollupOptions: {
317
+ plugins: []
318
+ }
319
+ }
320
+ };
321
+ if (isBuild) {
322
+ userConfig.build.rollupOptions.plugins = [
323
+ (0, import_rollup_plugin_external_globals.default)(externalMap)
324
+ ];
325
+ }
326
+ return userConfig;
327
+ },
328
+ transformIndexHtml(html) {
329
+ if (!isBuild && !enableInDevMode) {
330
+ return html;
331
+ }
332
+ const descriptors = [];
333
+ data.forEach((v) => {
334
+ v.pathList.forEach((url) => {
335
+ const cusomize = (generateScriptTag == null ? void 0 : generateScriptTag(v.name, url)) || {};
336
+ const attrs = __spreadValues({
337
+ src: url,
338
+ crossorigin: "anonymous"
339
+ }, cusomize.attrs);
340
+ descriptors.push(__spreadProps(__spreadValues({
341
+ tag: "script"
342
+ }, cusomize), {
343
+ attrs
344
+ }));
345
+ });
346
+ v.cssList.forEach((url) => {
347
+ const cusomize = (generateCssLinkTag == null ? void 0 : generateCssLinkTag(v.name, url)) || {};
348
+ const attrs = __spreadValues({
349
+ href: url,
350
+ rel: "stylesheet",
351
+ crossorigin: "anonymous"
352
+ }, cusomize.attrs);
353
+ descriptors.push(__spreadProps(__spreadValues({
354
+ tag: "link"
355
+ }, cusomize), {
356
+ attrs
357
+ }));
358
+ });
359
+ });
360
+ return descriptors;
361
+ }
362
+ }
363
+ ];
364
+ if (isDev2 && enableInDevMode) {
365
+ plugins.push(
366
+ (0, import_vite_plugin_externals.viteExternalsPlugin)(externalMap, {
367
+ enforce: "pre"
368
+ })
369
+ );
370
+ }
371
+ return plugins;
372
+ }
373
+ var autoComplete2 = autoComplete_default;
374
+ var src_default = PluginImportToCDN;
375
+ // Annotate the CommonJS export names for ESM import in node:
376
+ 0 && (module.exports = {
377
+ Plugin,
378
+ autoComplete
379
+ });