fix(chore): replace unpkg with npmmirror (#149)

* fix(chore): replace unpkg with npmmirror

* fix(dev): dev environment use node_moduels

* fix(chore): sync version

* fix(preview): use npmmirror link

* fix(preview): devtoolapi use unpkg link

* fix(preview): import map add esm cdn

* fix(version): fix tiny-vue version

* fix(version): fix tiny-vue version

* fix(version): fix tiny-vue version
This commit is contained in:
chilingling 2023-12-15 00:08:26 -08:00 committed by GitHub
parent 1d4c32e279
commit 11e302f1f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 34 deletions

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://unpkg.com/@opentiny/vue-theme@3/index.css" rel="stylesheet" />
<link href="https://registry.npmmirror.com/@opentiny/vue-theme/3.10/files/index.css" rel="stylesheet" />
<style type="text/css">
.loading-warp {
display: flex;

View File

@ -79,6 +79,7 @@
"@opentiny/tiny-engine-webcomponent-core": "workspace:^1.0.0",
"@opentiny/vue": "~3.10.0",
"@opentiny/vue-design-smb": "~3.10.0",
"@opentiny/vue-renderless": "~3.10.0",
"@opentiny/vue-theme": "~3.10.0",
"@vue/babel-plugin-jsx": "1.1.1",
"@vue/repl": "^1.3.0",
@ -97,6 +98,7 @@
"xlsx": "^0.18.5"
},
"devDependencies": {
"@opentiny/tiny-engine-i18n-host": "workspace:*",
"@babel/eslint-parser": "^7.21.3",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",

View File

@ -18,29 +18,30 @@ const importMap = {}
const tinyVue3Imports = {
// 推荐之后统一使用@opentiny/vue去引入依赖兼容后续录入的组件来源于tiny-vue
'@opentiny/vue': 'https://unpkg.com/@opentiny/vue@3/runtime/tiny-vue.mjs',
'@opentiny/vue-icon': 'https://unpkg.com/@opentiny/vue@3/runtime/tiny-vue-icon.mjs',
'@opentiny/vue-common': 'https://unpkg.com/@opentiny/vue@3/runtime/tiny-vue-common.mjs',
'@opentiny/vue-locale': 'https://unpkg.com/@opentiny/vue@3/runtime/tiny-vue-locale.mjs',
'@opentiny/vue-renderless/': 'https://unpkg.com/@opentiny/vue-renderless@3/'
'@opentiny/vue': 'https://registry.npmmirror.com/@opentiny/vue/3.11/files/runtime/tiny-vue.mjs',
'@opentiny/vue-icon': 'https://registry.npmmirror.com/@opentiny/vue/3.11/files/runtime/tiny-vue-icon.mjs',
'@opentiny/vue-common': 'https://registry.npmmirror.com/@opentiny/vue/3.11/files/runtime/tiny-vue-common.mjs',
'@opentiny/vue-locale': 'https://registry.npmmirror.com/@opentiny/vue/3.11/files/runtime/tiny-vue-locale.mjs',
'@opentiny/vue-renderless/': 'https://esm.sh/@opentiny/vue-renderless@3.11/?raw'
}
importMap.imports = {
vue: 'https://unpkg.com/vue@3.2.36/dist/vue.runtime.esm-browser.js',
'vue/server-renderer': 'https://unpkg.com/@vue/server-renderer@3.2.36/dist/server-renderer.esm-browser.js',
'vue-i18n': 'https://unpkg.com/vue-i18n@9.2.0-beta.36/dist/vue-i18n.esm-browser.js',
'vue-router': 'https://unpkg.com/vue-router@4.0.16/dist/vue-router.esm-browser.js',
'@vue/devtools-api': 'https://unpkg.com/@vue/devtools-api@6.1.4/lib/esm/index.js',
'@vueuse/core': 'https://unpkg.com/@vueuse/core@9.6.0/index.mjs',
'@vueuse/shared': 'https://unpkg.com/@vueuse/shared@9.6.0/index.mjs',
axios: 'https://unpkg.com/axios@1.0.0-alpha.1/dist/esm/axios.js',
'axios-mock-adapter': 'https://unpkg.com/axios-mock-adapter@1.21.1/dist/axios-mock-adapter.js',
vue: 'https://registry.npmmirror.com/vue/3.2.36/files/dist/vue.esm-browser.js',
'vue/server-renderer':
'https://registry.npmmirror.com/vue/server-renderer/3.2.36/files/dist/server-renderer.esm-browser.js',
'vue-i18n': 'https://registry.npmmirror.com/vue-i18n/9.2.0/files/dist/vue-i18n.esm-browser.js',
'vue-router': 'https://registry.npmmirror.com/vue-router/4.0.16/files/dist/vue-router.esm-browser.js',
'@vue/devtools-api': 'https://esm.sh/@vue/devtools-api@6.1.4/lib/esm/index.js?raw',
'@vueuse/core': 'https://registry.npmmirror.com/@vueuse/core/9.6.0/files/index.mjs',
'@vueuse/shared': 'https://registry.npmmirror.com/@vueuse/shared/9.6.0/files/index.mjs',
axios: 'https://registry.npmmirror.com/axios/1.0.0-alpha.1/files/dist/esm/axios.js',
'axios-mock-adapter': 'https://registry.npmmirror.com/axios-mock-adapter/1.21.1/files/dist/axios-mock-adapter.js',
'@opentiny/tiny-engine-webcomponent-core':
'https://unpkg.com/@opentiny/tiny-engine-webcomponent-core@1/dist/tiny-engine-webcomponent-core.es.js',
'https://registry.npmmirror.com/@opentiny/tiny-engine-webcomponent-core/1/files/dist/tiny-engine-webcomponent-core.es.js',
'@opentiny/tiny-engine-i18n-host':
'https://unpkg.com/@opentiny/tiny-engine-i18n-host@1/dist/tiny-engine-i18n-host.es.js',
'vue-demi': 'https://unpkg.com/vue-demi@0.13.11/lib/index.mjs',
pinia: 'https://unpkg.com/pinia@2.0.22/dist/pinia.esm-browser.js',
'https://registry.npmmirror.com/@opentiny/tiny-engine-i18n-host/1/files/dist/tiny-engine-i18n-host.es.js',
'vue-demi': 'https://registry.npmmirror.com/vue-demi/0.13.11/files/lib/index.mjs',
pinia: 'https://registry.npmmirror.com/pinia/2.0.22/files/dist/pinia.esm-browser.js',
...tinyVue3Imports,
...getSearchParams().scripts
}

View File

@ -1,14 +1,14 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
function addCss(href) {
const link = document.createElement('link')
@ -16,5 +16,5 @@ function addCss(href) {
link.setAttribute('href', href)
document.head.appendChild(link)
}
addCss('https://unpkg.com/@opentiny/vue-theme@3/index.css')
addCss('https://unpkg.com/@opentiny/vue-theme-mobile@3/index.css')
addCss('https://registry.npmmirror.com/@opentiny/vue-theme/3.10/files/index.css')
addCss('https://registry.npmmirror.com/@opentiny/vue-theme-mobile/3.10/files/index.css')

View File

@ -121,7 +121,7 @@ const config = {
const importMapVersions = {
prettier: '2.7.1',
vue: '3',
tinyVue: '3'
tinyVue: '~3.11'
}
const devAlias = {
@ -177,7 +177,7 @@ const devAlias = {
const devVueAlias = {
find: /^vue$/,
replacement: `https://unpkg.com/vue@${importMapVersions.vue}/dist/vue.runtime.esm-browser.js`
replacement: `https://registry.npmmirror.com/vue/${importMapVersions.vue}/files/dist/vue.runtime.esm-browser.js`
}
const prodAlias = {
@ -270,7 +270,11 @@ export default defineConfig(({ command, mode }) => {
}
}
config.plugins.push(monacoEditorPluginInstance, htmlPlugin(mode), importmapPlugin(importmap, importMapStyles))
config.plugins.push(
monacoEditorPluginInstance,
htmlPlugin(mode),
command === 'build' && importmapPlugin(importmap, importMapStyles)
)
return config
})