fix(build): exposing installer function and version for umd build (#3041)

* fix(build): exposing installer function and version for umd build

* fix codepen code snippet error
This commit is contained in:
jeremywu 2021-08-25 11:27:16 +08:00 committed by GitHub
parent 84d8d7111e
commit e926d20179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 15 deletions

View File

@ -61,12 +61,6 @@ import { EP_PREFIX, excludes } from './constants'
plugins: [...config.plugins, RollupResolveEntryPlugin()],
})
console.log(chalk.yellow('Generating index.js'))
await bundle.write(umd as any)
console.log(chalk.green('index.js generated'))
console.log(chalk.yellow('Generating index.full.js'))
await bundle.write(umdMinified as any)

View File

@ -1,3 +1,4 @@
import installer from './defaults'
export * from '@element-plus/components'
export * from '@element-plus/directives'
export * from '@element-plus/hooks'
@ -5,3 +6,6 @@ export * from '@element-plus/tokens'
export { default as makeInstaller } from './make-installer'
export { default } from './defaults'
export const install = installer.install
export const version = installer.version

View File

@ -88,13 +88,9 @@ function template(str: string, option) {
})
}
export const localeProviderMaker = ({
locale,
}: {
locale?: Language
}) => {
const lang = ref((locale || English).name)
const localeRef = ref(locale || English)
export const localeProviderMaker = (locale = English) => {
const lang = ref(locale.name)
const localeRef = ref(locale)
return {
lang,
locale: localeRef,

View File

@ -262,9 +262,9 @@ ${this.codepen.style}
// since 2.6.2 use code rather than jsfiddle https://blog.codepen.io/documentation/api/prefill/
const { script, html, style } = this.codepen
const resourcesTpl = '<scr' + 'ipt src="//unpkg.com/vue@next"></scr' + 'ipt>' +
'\n<scr' + `ipt src="//unpkg.com/element-plus/lib/index.full.js"></scr` + 'ipt>'
'\n<scr' + `ipt src="//unpkg.com/element-plus/dist/index.full.js"></scr` + 'ipt>'
let htmlTpl = `${resourcesTpl}\n<div id="app">\n${html.trim()}\n</div>`
let cssTpl = `@import url("//unpkg.com/element-plus/lib/theme-chalk/index.css");\n${(style || '').trim()}\n`
let cssTpl = `@import url("//unpkg.com/element-plus/dist/index.css");\n${(style || '').trim()}\n`
let jsTpl = script ? script.replace(/export default/, 'var Main =').trim().replace(/import ({.*}) from 'vue'/g, (s, s1) => `const ${s1} = Vue`).replace(/import ({.*}) from 'element-plus'/g, (s, s1) => `const ${s1} = ElementPlus`) : 'var Main = {}'
jsTpl += '\n;const app = Vue.createApp(Main);\napp.use(ElementPlus);\napp.mount("#app")'
const data = {