Skip to content

Commit

Permalink
fix: load vue from @vue/cli-service-global on vue serve/`vue buil…
Browse files Browse the repository at this point in the history
…d` (#5774)
  • Loading branch information
sodatea committed Aug 11, 2020
1 parent b85f5f2 commit 8cf3745
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/@vue/cli-service/lib/config/base.js
Expand Up @@ -69,9 +69,11 @@ module.exports = (api, options) => {
// js is handled by cli-plugin-babel ---------------------------------------

// vue-loader --------------------------------------------------------------
const vue = loadModule('vue', api.service.context)
// try to load vue in the project
// fallback to peer vue package in the instant prototyping environment
const vue = loadModule('vue', api.service.context) || loadModule('vue', __dirname)

if (semver.major(vue.version) === 2) {
if (vue && semver.major(vue.version) === 2) {
// for Vue 2 projects
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', {
'vue-loader': require('vue-loader/package.json').version,
Expand Down Expand Up @@ -106,7 +108,7 @@ module.exports = (api, options) => {
webpackConfig
.plugin('vue-loader')
.use(require('vue-loader').VueLoaderPlugin)
} else if (semver.major(vue.version) === 3) {
} else if (vue && semver.major(vue.version) === 3) {
// for Vue 3 projects
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', {
'vue-loader': require('vue-loader-v16/package.json').version,
Expand Down

0 comments on commit 8cf3745

Please sign in to comment.