diff --git a/build/webpack.config.js b/build/webpack.config.js index b737bb0178..f448544dd1 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -19,7 +19,9 @@ const plugins = [ new VueLoaderPlugin(), // new BundleAnalyzerPlugin(), ] -let entry = [path.resolve(__dirname, '../packages/element-plus/index.ts')] + +const entry = path.resolve(__dirname, '../packages/element-plus/index.ts') + if (!isFullMode) { externals.push({ '@popperjs/core': '@popperjs/core', @@ -30,8 +32,6 @@ if (!isFullMode) { }, /^dayjs.*/, /^lodash.*/) -} else { - entry.push(path.resolve(__dirname, '../packages/element-plus/full.ts')) } const config = { diff --git a/packages/element-plus/full.ts b/packages/element-plus/full.ts deleted file mode 100644 index 3e6dd8d2b8..0000000000 --- a/packages/element-plus/full.ts +++ /dev/null @@ -1,4 +0,0 @@ -import dayjs from 'dayjs' - -// expose Day.js to window to make full bundle i18n work -(window as any).dayjs = dayjs diff --git a/packages/element-plus/index.ts b/packages/element-plus/index.ts index 060ffef0bc..0f5df110ef 100644 --- a/packages/element-plus/index.ts +++ b/packages/element-plus/index.ts @@ -95,6 +95,13 @@ import { use, i18n } from '@element-plus/locale' import { version as version_ } from './version' import type { InstallOptions } from '@element-plus/utils/config' import { setConfig } from '@element-plus/utils/config' +import isServer from '@element-plus/utils/isServer' +import dayjs from 'dayjs' + +// expose Day.js to window to make full bundle i18n work +if (!isServer && !(window as any).dayjs) { + (window as any).dayjs = dayjs +} const version = version_ // version_ to fix tsc issue