xiaoxian521
2 years ago
9 changed files with 126 additions and 4 deletions
-
3.env.production
-
3.env.staging
-
67build/cdn.ts
-
3build/index.ts
-
8build/plugins.ts
-
1package.json
-
39pnpm-lock.yaml
-
1types/global.d.ts
-
3vite.config.ts
@ -0,0 +1,67 @@ |
|||
import { Plugin as importToCDN } from "vite-plugin-cdn-import"; |
|||
|
|||
/** |
|||
* @description 打包时采用`cdn`模式,仅限外网使用(默认不采用,如果需要采用cdn模式,请在 .env.production 文件,将 VITE_CDN 设置成true) |
|||
* 平台采用国内cdn:https://www.bootcdn.cn,当然你也可以选择 https://unpkg.com 或者 https://www.jsdelivr.com
|
|||
* 提醒:mockjs不能用cdn模式引入,会报错。正确的方式是,生产环境删除mockjs,使用真实的后端请求 |
|||
* 注意:上面提到的仅限外网使用也不是完全肯定的,如果你们公司内网部署的有相关js、css文件,也可以将下面配置对应改一下,整一套内网版cdn |
|||
*/ |
|||
export const cdn = importToCDN({ |
|||
//(prodUrl解释: name: 对应下面modules的name,version: 自动读取本地package.json中dependencies依赖中对应包的版本号,path: 对应下面modules的path)
|
|||
prodUrl: "https://cdn.bootcdn.net/ajax/libs/{name}/{version}/{path}", |
|||
modules: [ |
|||
{ |
|||
name: "vue", |
|||
var: "Vue", |
|||
path: "vue.global.prod.min.js" |
|||
}, |
|||
{ |
|||
name: "vue-router", |
|||
var: "VueRouter", |
|||
path: "vue-router.global.min.js" |
|||
}, |
|||
{ |
|||
name: "vue-i18n", |
|||
var: "VueI18n", |
|||
path: "vue-i18n.runtime.global.prod.min.js" |
|||
}, |
|||
// 项目中没有直接安装vue-demi,但是pinia用到了,所以需要在引入pinia前引入vue-demi(https://github.com/vuejs/pinia/blob/v2/packages/pinia/package.json#L77)
|
|||
{ |
|||
name: "vue-demi", |
|||
var: "VueDemi", |
|||
path: "index.iife.min.js" |
|||
}, |
|||
{ |
|||
name: "pinia", |
|||
var: "Pinia", |
|||
path: "pinia.iife.min.js" |
|||
}, |
|||
{ |
|||
name: "element-plus", |
|||
var: "ElementPlus", |
|||
path: "index.full.min.js", |
|||
css: "index.min.css" |
|||
}, |
|||
{ |
|||
name: "axios", |
|||
var: "axios", |
|||
path: "axios.min.js" |
|||
}, |
|||
{ |
|||
name: "dayjs", |
|||
var: "dayjs", |
|||
path: "dayjs.min.js" |
|||
}, |
|||
{ |
|||
name: "echarts", |
|||
var: "echarts", |
|||
path: "echarts.min.js" |
|||
}, |
|||
{ |
|||
name: "lodash", |
|||
var: "lodash", |
|||
// 可写`完整路径`,会替换`prodUrl`
|
|||
path: "https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js" |
|||
} |
|||
] |
|||
}); |
@ -81,6 +81,7 @@ specifiers: |
|||
typescript: ^4.7.4 |
|||
unplugin-vue-define-options: 0.7.3 |
|||
vite: ^3.1.8 |
|||
vite-plugin-cdn-import: ^0.3.5 |
|||
vite-plugin-mock: ^2.9.6 |
|||
vite-plugin-remove-console: ^1.1.0 |
|||
vite-svg-loader: ^3.6.0 |
|||
@ -182,6 +183,7 @@ devDependencies: |
|||
typescript: 4.8.4 |
|||
unplugin-vue-define-options: 0.7[email protected][email protected] |
|||
vite: 3.1[email protected][email protected] |
|||
vite-plugin-cdn-import: 0.3.5 |
|||
vite-plugin-mock: 2.9[email protected][email protected] |
|||
vite-plugin-remove-console: 1.1.0 |
|||
vite-svg-loader: 3.6.0 |
|||
@ -4670,6 +4672,15 @@ packages: |
|||
} |
|||
engines: { node: ">=0.10.0" } |
|||
|
|||
/is-reference/1.2.1: |
|||
resolution: |
|||
{ |
|||
integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== |
|||
} |
|||
dependencies: |
|||
"@types/estree": 0.0.39 |
|||
dev: true |
|||
|
|||
/is-regexp/1.0.0: |
|||
resolution: |
|||
{ |
|||
@ -6524,6 +6535,23 @@ packages: |
|||
glob: 7.2.3 |
|||
dev: true |
|||
|
|||
/rollup-plugin-external-globals/0.6.1: |
|||
resolution: |
|||
{ |
|||
integrity: sha512-mlp3KNa5sE4Sp9UUR2rjBrxjG79OyZAh/QC18RHIjM+iYkbBwNXSo8DHRMZWtzJTrH8GxQ+SJvCTN3i14uMXIA== |
|||
} |
|||
peerDependencies: |
|||
rollup: ^2.25.0 |
|||
peerDependenciesMeta: |
|||
rollup: |
|||
optional: true |
|||
dependencies: |
|||
"@rollup/pluginutils": 4.2.1 |
|||
estree-walker: 2.0.2 |
|||
is-reference: 1.2.1 |
|||
magic-string: 0.25.9 |
|||
dev: true |
|||
|
|||
/rollup-plugin-visualizer/5.8.3: |
|||
resolution: |
|||
{ |
|||
@ -7499,6 +7527,17 @@ packages: |
|||
spdx-expression-parse: 3.0.1 |
|||
dev: true |
|||
|
|||
/vite-plugin-cdn-import/0.3.5: |
|||
resolution: |
|||
{ |
|||
integrity: sha512-e1raoalfBiIhv+hnMeSp1UNjloDDBhHpeFxkwRRdPBmTdDRqdEEn8owUmT5u8UBSVCs4xN3n/od4a91vXEhXPQ== |
|||
} |
|||
dependencies: |
|||
rollup-plugin-external-globals: 0.6.1 |
|||
transitivePeerDependencies: |
|||
- rollup |
|||
dev: true |
|||
|
|||
/vite-plugin-mock/[email protected][email protected]: |
|||
resolution: |
|||
{ |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue