Commit a90d93fc4d8dd8491702183f3db700c33dbcc5a8
1 parent
1093ec3e
fix: fix win system dynamicImport error
Showing
5 changed files
with
14 additions
and
24 deletions
build/vite/cdn.ts deleted
100644 → 0
1 | -const css = ['//cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.css']; | ||
2 | - | ||
3 | -// TODO use esm? | ||
4 | -const js = [ | ||
5 | - '//cdn.bootcdn.net/ajax/libs/vue/3.0.0/vue.global.prod.js', | ||
6 | - '//cdn.bootcdn.net/ajax/libs/vue-router/4.0.0-beta.13/vue-router.global.min.js', | ||
7 | - '//cdn.bootcdn.net/ajax/libs/vuex/4.0.0-beta.4/vuex.global.prod.js', | ||
8 | - '//cdn.bootcdn.net/ajax/libs/axios/0.19.2/axios.min.js', | ||
9 | - '//cdn.bootcdn.net/ajax/libs/qs/6.9.4/qs.min.js', | ||
10 | - '//cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.js', | ||
11 | - // '//cdn.bootcdn.net/ajax/libs/lodash.js/4.17.15/lodash.min.js', | ||
12 | - // '//cdn.bootcdn.net/ajax/libs/crypto-js/3.3.0/crypto-js.min.js', | ||
13 | - // '//cdn.bootcdn.net/ajax/libs/vue-i18n/8.18.1/vue-i18n.min.js', | ||
14 | -]; | ||
15 | - | ||
16 | -export const externals = ['vue', 'vuex', 'vue-router', 'axios', 'qs', 'nprogress']; | ||
17 | - | ||
18 | -export const cdnConf = { | ||
19 | - css, | ||
20 | - js, | ||
21 | -}; |
build/vite/plugin/dynamicImport/index.ts
@@ -17,7 +17,10 @@ const dynamicImportTransform = function (env: any = {}): Transform { | @@ -17,7 +17,10 @@ const dynamicImportTransform = function (env: any = {}): Transform { | ||
17 | return { | 17 | return { |
18 | test({ path }) { | 18 | test({ path }) { |
19 | // Only convert the file | 19 | // Only convert the file |
20 | - return path.includes('/src/utils/helper/dynamicImport.ts'); | 20 | + return ( |
21 | + path.includes('/src/utils/helper/dynamicImport.ts') || | ||
22 | + path.includes(`\\src\\utils\\helper\\dynamicImport.ts`) | ||
23 | + ); | ||
21 | }, | 24 | }, |
22 | transform({ code }) { | 25 | transform({ code }) { |
23 | const { VITE_DYNAMIC_IMPORT } = env; | 26 | const { VITE_DYNAMIC_IMPORT } = env; |
src/utils/helper/dynamicImport.ts
1 | +// The content here is just for type approval. The actual file content is overwritten by transform | ||
1 | export default function (id: string) { | 2 | export default function (id: string) { |
2 | const dynamicImportModule: any = id; | 3 | const dynamicImportModule: any = id; |
3 | return dynamicImportModule; | 4 | return dynamicImportModule; |
src/utils/helper/routeHelper.ts
@@ -53,7 +53,6 @@ export function genRouteModule(moduleList: AppRouteModule[]) { | @@ -53,7 +53,6 @@ export function genRouteModule(moduleList: AppRouteModule[]) { | ||
53 | } | 53 | } |
54 | 54 | ||
55 | // 动态引入 | 55 | // 动态引入 |
56 | -// TODO 错误写法 | ||
57 | function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) { | 56 | function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) { |
58 | if (!routes) return; | 57 | if (!routes) return; |
59 | routes.forEach((item) => { | 58 | routes.forEach((item) => { |
yarn.lock
@@ -6944,7 +6944,7 @@ rollup@^1.31.1: | @@ -6944,7 +6944,7 @@ rollup@^1.31.1: | ||
6944 | "@types/node" "*" | 6944 | "@types/node" "*" |
6945 | acorn "^7.1.0" | 6945 | acorn "^7.1.0" |
6946 | 6946 | ||
6947 | -rollup@^2.32.1: | 6947 | +rollup@^2.32.1, rollup@^2.33.1: |
6948 | version "2.33.1" | 6948 | version "2.33.1" |
6949 | resolved "https://registry.npmjs.org/rollup/-/rollup-2.33.1.tgz#802795164164ee63cd47769d8879c33ec8ae0c40" | 6949 | resolved "https://registry.npmjs.org/rollup/-/rollup-2.33.1.tgz#802795164164ee63cd47769d8879c33ec8ae0c40" |
6950 | integrity sha512-uY4O/IoL9oNW8MMcbA5hcOaz6tZTMIh7qJHx/tzIJm+n1wLoY38BLn6fuy7DhR57oNFLMbDQtDeJoFURt5933w== | 6950 | integrity sha512-uY4O/IoL9oNW8MMcbA5hcOaz6tZTMIh7qJHx/tzIJm+n1wLoY38BLn6fuy7DhR57oNFLMbDQtDeJoFURt5933w== |
@@ -8162,6 +8162,14 @@ vfile@^4.0.0: | @@ -8162,6 +8162,14 @@ vfile@^4.0.0: | ||
8162 | unist-util-stringify-position "^2.0.0" | 8162 | unist-util-stringify-position "^2.0.0" |
8163 | vfile-message "^2.0.0" | 8163 | vfile-message "^2.0.0" |
8164 | 8164 | ||
8165 | +vite-plugin-cdn@^1.0.0-beta.3: | ||
8166 | + version "1.0.0-beta.3" | ||
8167 | + resolved "https://registry.npmjs.org/vite-plugin-cdn/-/vite-plugin-cdn-1.0.0-beta.3.tgz#5846e80debba5e3968169931f5cba86aea5701cd" | ||
8168 | + integrity sha512-1oepxSSr8rROFhyP93EWVasKHAAbGfp3QyUrUmJW/zU80CvFPyHATckk8vy08pMiulErSqATjfofTJ+TxP4wkw== | ||
8169 | + dependencies: | ||
8170 | + lodash "^4.17.20" | ||
8171 | + rollup "^2.33.1" | ||
8172 | + | ||
8165 | vite-plugin-html@^1.0.0-beta.2: | 8173 | vite-plugin-html@^1.0.0-beta.2: |
8166 | version "1.0.0-beta.2" | 8174 | version "1.0.0-beta.2" |
8167 | resolved "https://registry.npmjs.org/vite-plugin-html/-/vite-plugin-html-1.0.0-beta.2.tgz#f30cdba4ca70469e62b770e32c407ce5d7f9b544" | 8175 | resolved "https://registry.npmjs.org/vite-plugin-html/-/vite-plugin-html-1.0.0-beta.2.tgz#f30cdba4ca70469e62b770e32c407ce5d7f9b544" |