Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复unpkg依赖 #188

Merged
merged 7 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions packages/design-core/public/mock/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
"script": "https://unpkg.com/[email protected]/dist/index.full.mjs",
"css": "https://unpkg.com/[email protected]/dist/index.css",
"script": "https://npm.onmicrosoft.cn/[email protected]/dist/index.full.mjs",
"css": "https://npm.onmicrosoft.cn/[email protected]/dist/index.css",
"dependencies": null,
"exportName": "ElInput"
},
Expand Down Expand Up @@ -300,8 +300,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
"script": "https://unpkg.com/[email protected]/dist/index.full.mjs",
"css": "https://unpkg.com/[email protected]/dist/index.css",
"script": "https://npm.onmicrosoft.cn/[email protected]/dist/index.full.mjs",
"css": "https://npm.onmicrosoft.cn/[email protected]/dist/index.css",
"dependencies": null,
"exportName": "ElButton"
},
Expand Down Expand Up @@ -621,8 +621,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
"script": "https://unpkg.com/[email protected]/dist/index.full.mjs",
"css": "https://unpkg.com/[email protected]/dist/index.css",
"script": "https://npm.onmicrosoft.cn/[email protected]/dist/index.full.mjs",
"css": "https://npm.onmicrosoft.cn/[email protected]/dist/index.css",
"dependencies": null,
"exportName": "ElForm"
},
Expand Down Expand Up @@ -1078,8 +1078,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
"script": "https://unpkg.com/[email protected]/dist/index.full.mjs",
"css": "https://unpkg.com/[email protected]/dist/index.css",
"script": "https://npm.onmicrosoft.cn/[email protected]/dist/index.full.mjs",
"css": "https://npm.onmicrosoft.cn/[email protected]/dist/index.css",
"dependencies": null,
"exportName": "ElFormItem"
},
Expand Down Expand Up @@ -1428,8 +1428,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
"script": "https://unpkg.com/[email protected]/dist/index.full.mjs",
"css": "https://unpkg.com/[email protected]/dist/index.css",
"script": "https://npm.onmicrosoft.cn/[email protected]/dist/index.full.mjs",
"css": "https://npm.onmicrosoft.cn/[email protected]/dist/index.css",
"dependencies": null,
"exportName": "ElTable"
},
Expand Down Expand Up @@ -2664,8 +2664,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
"script": "https://unpkg.com/[email protected]/dist/index.full.mjs",
"css": "https://unpkg.com/[email protected]/dist/index.css",
"script": "https://npm.onmicrosoft.cn/[email protected]/dist/index.full.mjs",
"css": "https://npm.onmicrosoft.cn/[email protected]/dist/index.css",
"dependencies": null,
"exportName": "ElTableColumn"
},
Expand Down
39 changes: 20 additions & 19 deletions packages/design-core/src/preview/src/preview/importMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,33 @@ import { getSearchParams } from './http'

const importMap = {}

const opentinyVueVersion = '~3.11'

const tinyVue3Imports = {
// 推荐之后统一使用@opentiny/vue去引入依赖,兼容后续录入的组件来源于tiny-vue
'@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'
'@opentiny/vue': `https://npm.onmicrosoft.cn/@opentiny/vue@${opentinyVueVersion}/runtime/tiny-vue.mjs`,
chilingling marked this conversation as resolved.
Show resolved Hide resolved
'@opentiny/vue-icon': `https://npm.onmicrosoft.cn/@opentiny/vue@${opentinyVueVersion}/runtime/tiny-vue-icon.mjs`,
'@opentiny/vue-common': `https://npm.onmicrosoft.cn/@opentiny/vue@${opentinyVueVersion}/runtime/tiny-vue-common.mjs`,
'@opentiny/vue-locale': `https://npm.onmicrosoft.cn/@opentiny/vue@${opentinyVueVersion}/runtime/tiny-vue-locale.mjs`,
'@opentiny/vue-renderless/': `https://npm.onmicrosoft.cn/@opentiny/vue-renderless@${opentinyVueVersion}/`
}

importMap.imports = {
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/[email protected]/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',
vue: 'https://npm.onmicrosoft.cn/[email protected]/dist/vue.runtime.esm-browser.js',
'vue/server-renderer': 'https://npm.onmicrosoft.cn/@vue/[email protected]/dist/server-renderer.esm-browser.js',
'vue-i18n': 'https://npm.onmicrosoft.cn/[email protected]/dist/vue-i18n.esm-browser.js',
'vue-router': 'https://npm.onmicrosoft.cn/[email protected]/dist/vue-router.esm-browser.js',
'@vue/devtools-api': 'https://npm.onmicrosoft.cn/@vue/[email protected]/lib/esm/index.js',
'@vueuse/core': 'https://npm.onmicrosoft.cn/@vueuse/[email protected]/index.mjs',
'@vueuse/shared': 'https://npm.onmicrosoft.cn/@vueuse/[email protected]/index.mjs',
axios: 'https://npm.onmicrosoft.cn/[email protected]/dist/esm/axios.js',
'axios-mock-adapter': 'https://npm.onmicrosoft.cn/[email protected]/dist/axios-mock-adapter.js',
'@opentiny/tiny-engine-webcomponent-core':
'https://registry.npmmirror.com/@opentiny/tiny-engine-webcomponent-core/1/files/dist/tiny-engine-webcomponent-core.es.js',
'https://npm.onmicrosoft.cn/@opentiny/tiny-engine-webcomponent-core@1/dist/tiny-engine-webcomponent-core.es.js',
'@opentiny/tiny-engine-i18n-host':
'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',
'https://npm.onmicrosoft.cn/@opentiny/tiny-engine-i18n-host@1/dist/tiny-engine-i18n-host.es.js',
'vue-demi': 'https://npm.onmicrosoft.cn/vue-demi@0.13.11/lib/index.mjs',
pinia: 'https://npm.onmicrosoft.cn/pinia@2.0.22/dist/pinia.esm-browser.js',
...tinyVue3Imports,
...getSearchParams().scripts
}
Expand Down
38 changes: 17 additions & 21 deletions packages/design-core/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const devAlias = {

const devVueAlias = {
find: /^vue$/,
replacement: `https://registry.npmmirror.com/vue/${importMapVersions.vue}/files/dist/vue.runtime.esm-browser.js`
replacement: `https://npm.onmicrosoft.cn/vue@${importMapVersions.vue}/dist/vue.runtime.esm-browser.js`
}

const prodAlias = {
Expand All @@ -193,25 +193,25 @@ const commonAlias = {

const importmap = {
imports: {
prettier: `https://unpkg.com/prettier@${importMapVersions.prettier}/esm/standalone.mjs`,
'prettier/': `https://unpkg.com/prettier@${importMapVersions.prettier}/esm/`,
'prettier/parser-typescript': `https://unpkg.com/prettier@${importMapVersions.prettier}/esm/parser-typescript.mjs`,
'prettier/parser-html': `https://unpkg.com/prettier@${importMapVersions.prettier}/esm/parser-html.mjs`,
'prettier/parser-postcss': `https://unpkg.com/prettier@${importMapVersions.prettier}/esm/parser-postcss.mjs`,
'prettier/parser-babel': `https://unpkg.com/prettier@${importMapVersions.prettier}/esm/parser-babel.mjs`,
prettier: `https://npm.onmicrosoft.cn/prettier@${importMapVersions.prettier}/esm/standalone.mjs`,
'prettier/': `https://npm.onmicrosoft.cn/prettier@${importMapVersions.prettier}/esm/`,
'prettier/parser-typescript': `https://npm.onmicrosoft.cn/prettier@${importMapVersions.prettier}/esm/parser-typescript.mjs`,
'prettier/parser-html': `https://npm.onmicrosoft.cn/prettier@${importMapVersions.prettier}/esm/parser-html.mjs`,
'prettier/parser-postcss': `https://npm.onmicrosoft.cn/prettier@${importMapVersions.prettier}/esm/parser-postcss.mjs`,
'prettier/parser-babel': `https://npm.onmicrosoft.cn/prettier@${importMapVersions.prettier}/esm/parser-babel.mjs`,

vue: `https://unpkg.com/vue@${importMapVersions.vue}/dist/vue.runtime.esm-browser.js`,
'@opentiny/vue': `https://unpkg.com/@opentiny/vue@${importMapVersions.tinyVue}/runtime/tiny-vue.mjs`,
'@opentiny/vue-icon': `https://unpkg.com/@opentiny/vue@${importMapVersions.tinyVue}/runtime/tiny-vue-icon.mjs`,
'@opentiny/vue-common': `https://unpkg.com/@opentiny/vue@${importMapVersions.tinyVue}/runtime/tiny-vue-common.mjs`,
'@opentiny/vue-locale': `https://unpkg.com/@opentiny/vue@${importMapVersions.tinyVue}/runtime/tiny-vue-locale.mjs`,
'@opentiny/vue-design-smb': `https://unpkg.com/@opentiny/vue-design-smb@${importMapVersions.tinyVue}/index.js`,
'@opentiny/vue-theme/theme-tool': `https://unpkg.com/@opentiny/vue-theme@${importMapVersions.tinyVue}/theme-tool`,
'@opentiny/vue-theme/theme': `https://unpkg.com/@opentiny/vue-theme@${importMapVersions.tinyVue}/theme`
vue: `https://npm.onmicrosoft.cn/vue@${importMapVersions.vue}/dist/vue.runtime.esm-browser.js`,
'@opentiny/vue': `https://npm.onmicrosoft.cn/@opentiny/vue@${importMapVersions.tinyVue}/runtime/tiny-vue.mjs`,
'@opentiny/vue-icon': `https://npm.onmicrosoft.cn/@opentiny/vue@${importMapVersions.tinyVue}/runtime/tiny-vue-icon.mjs`,
'@opentiny/vue-common': `https://npm.onmicrosoft.cn/@opentiny/vue@${importMapVersions.tinyVue}/runtime/tiny-vue-common.mjs`,
'@opentiny/vue-locale': `https://npm.onmicrosoft.cn/@opentiny/vue@${importMapVersions.tinyVue}/runtime/tiny-vue-locale.mjs`,
'@opentiny/vue-design-smb': `https://npm.onmicrosoft.cn/@opentiny/vue-design-smb@${importMapVersions.tinyVue}/index.js`,
'@opentiny/vue-theme/theme-tool': `https://npm.onmicrosoft.cn/@opentiny/vue-theme@${importMapVersions.tinyVue}/theme-tool`,
'@opentiny/vue-theme/theme': `https://npm.onmicrosoft.cn/@opentiny/vue-theme@${importMapVersions.tinyVue}/theme`
}
}

const importMapStyles = [`https://unpkg.com/@opentiny/vue-theme@${importMapVersions.tinyVue}/index.css`]
const importMapStyles = [`https://npm.onmicrosoft.cn/@opentiny/vue-theme@${importMapVersions.tinyVue}/index.css`]

export default defineConfig(({ command, mode }) => {
const monacoPublicPath = {
Expand Down Expand Up @@ -270,11 +270,7 @@ export default defineConfig(({ command, mode }) => {
}
}

config.plugins.push(
monacoEditorPluginInstance,
htmlPlugin(mode),
command === 'build' && importmapPlugin(importmap, importMapStyles)
)
config.plugins.push(monacoEditorPluginInstance, htmlPlugin(mode), importmapPlugin(importmap, importMapStyles))

return config
})