Skip to content

Commit

Permalink
🎨 fix(template): fix template build error
Browse files Browse the repository at this point in the history
  • Loading branch information
ErKeLost committed Aug 14, 2022
1 parent bc46f85 commit 68a8976
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ async function installationDeps() {
console.log('')
cyan('Project created successfully')
console.log('')
cyan(` cd ${options.name}`)
cyan(`cd ${options.name}`)
cyan(
options.package === 'npm'
? ` ${options.package} run dev`
: ` ${options.package} dev`
? `${options.package} run dev`
: `${options.package} dev`
)
}
export default installationDeps
7 changes: 6 additions & 1 deletion packages/vite-cli/src/core/questions/vue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
lintMap,
pluginMap,
pluginImportStatement,
componentResolverMap
componentResolverMap,
notComponentResolverMap
} from '@/shared/vueEjsMapConstant'
import createQuestion from '@/utils/question'
async function getVueProperty() {
Expand All @@ -20,8 +21,12 @@ async function getVueProperty() {
const Router = futureMap.get('Router')
const Pinia = futureMap.get('Pinia')
const currentComponentResolver = componentResolverMap.get(options.components)
const notComponentResolver = notComponentResolverMap.includes(
options.components
)
options.ui = currentLibrary
options.ComponentResolver = currentComponentResolver
options.notComponentResolver = notComponentResolver
options.EslintScript = lintMap.get('EslintScript')
options.PrettierScript = lintMap.get('PrettierScript')
options.EslintWithPrettierScript = lintMap.get('EslintWithPrettierScript')
Expand Down
1 change: 1 addition & 0 deletions packages/vite-cli/src/shared/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface Options {
pluginImportStatement?: string
// vue-components-import
ComponentResolver?: string
notComponentResolver?: boolean
}

const options: Options = {
Expand Down
3 changes: 3 additions & 0 deletions packages/vite-cli/src/shared/vueEjsMapConstant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,22 @@ const pluginImportStatement = new Map([
])
const componentResolverMap = new Map([
['element-plus', 'ElementPlusResolver'],
['vuetify', 'VuetifyResolver'],
['arco', 'ArcoResolver'],
['naive-ui', 'NaiveUiResolver'],
['tencent', 'TDesignResolver'],
['devui', 'DevUiResolver'],
['ant-design', 'AntDesignVueResolver'],
['varlet', 'VarletUIResolver']
])
const notComponentResolverMap = ['vuetify', 'ant-design']

export {
componentsMap,
futureMap,
lintMap,
pluginMap,
componentResolverMap,
notComponentResolverMap,
pluginImportStatement
}
4 changes: 2 additions & 2 deletions packages/vite-cli/template/vue/build/vite/plugin.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export function createVitePlugins(viteEnv, isDev: boolean) {
prefix: "Icon"
}),
<% } -%>
<% if (components !== 'vuetify' || components !== 'ant-design') { -%>
<%- ComponentResolver %>()
<% if (!notComponentResolver) { -%>
<%- ComponentResolver + '()' %>
<% } -%>
],
dts: "src/types/components.d.ts"
Expand Down

0 comments on commit 68a8976

Please sign in to comment.