Skip to content

Commit 8d767a1

Browse files
bteasxzz
authored andcommitted
feat(element-plus): support nightly option (#685)
1 parent 1f8e146 commit 8d767a1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/core/resolvers/element-plus.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export interface ElementPlusResolverOptions {
3838
* a list of component names that have no styles, so resolving their styles file should be prevented
3939
*/
4040
noStylesComponents?: string[]
41+
42+
/**
43+
* nightly version
44+
*/
45+
nightly?: boolean
4146
}
4247

4348
type ElementPlusResolverOptionsResolved = Required<Omit<ElementPlusResolverOptions, 'exclude'>> &
@@ -73,9 +78,9 @@ function getSideEffectsLegacy(
7378
}
7479

7580
function getSideEffects(dirName: string, options: ElementPlusResolverOptionsResolved): SideEffectsInfo | undefined {
76-
const { importStyle, ssr } = options
77-
const themeFolder = 'element-plus/theme-chalk'
78-
const esComponentsFolder = 'element-plus/es/components'
81+
const { importStyle, ssr, nightly } = options
82+
const themeFolder = nightly ? '@element-plus/nightly/theme-chalk' : 'element-plus/theme-chalk'
83+
const esComponentsFolder = nightly ? '@element-plus/nightly/es/components' : 'element-plus/es/components'
7984

8085
if (importStyle === 'sass') {
8186
return ssr
@@ -104,13 +109,13 @@ function resolveComponent(name: string, options: ElementPlusResolverOptionsResol
104109
}
105110

106111
const partialName = kebabCase(name.slice(2))// ElTableColumn -> table-column
107-
const { version, ssr } = options
112+
const { version, ssr, nightly } = options
108113

109114
// >=1.1.0-beta.1
110-
if (compare(version, '1.1.0-beta.1', '>=')) {
115+
if (compare(version, '1.1.0-beta.1', '>=') || nightly) {
111116
return {
112117
name,
113-
from: `element-plus/${ssr ? 'lib' : 'es'}`,
118+
from: `${nightly ? '@element-plus/nightly' : 'element-plus'}/${ssr ? 'lib' : 'es'}`,
114119
sideEffects: getSideEffects(partialName, options),
115120
}
116121
}
@@ -144,13 +149,13 @@ function resolveDirective(name: string, options: ElementPlusResolverOptionsResol
144149
if (!directive)
145150
return
146151

147-
const { version, ssr } = options
152+
const { version, ssr, nightly } = options
148153

149154
// >=1.1.0-beta.1
150-
if (compare(version, '1.1.0-beta.1', '>=')) {
155+
if (compare(version, '1.1.0-beta.1', '>=') || nightly) {
151156
return {
152157
name: directive.importName,
153-
from: `element-plus/${ssr ? 'lib' : 'es'}`,
158+
from: `${nightly ? '@element-plus/nightly' : 'element-plus'}/${ssr ? 'lib' : 'es'}`,
154159
sideEffects: getSideEffects(directive.styleName, options),
155160
}
156161
}
@@ -183,6 +188,7 @@ export function ElementPlusResolver(
183188
directives: true,
184189
exclude: undefined,
185190
noStylesComponents: options.noStylesComponents || [],
191+
nightly: false,
186192
...options,
187193
}
188194
return optionsResolved

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy