Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: load vue from @vue/cli-service-global on vue serve/vue build #5774

Merged
merged 2 commits into from Aug 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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