Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8cf3745

Browse filesBrowse files
authored
fix: load vue from @vue/cli-service-global on vue serve/vue build (#5774)
1 parent b85f5f2 commit 8cf3745
Copy full SHA for 8cf3745

File tree

Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed
Filter options
  • packages/@vue/cli-service/lib/config
Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed

‎packages/@vue/cli-service/lib/config/base.js

Copy file name to clipboardExpand all lines: packages/@vue/cli-service/lib/config/base.js
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ module.exports = (api, options) => {
6969
// js is handled by cli-plugin-babel ---------------------------------------
7070

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

74-
if (semver.major(vue.version) === 2) {
76+
if (vue && semver.major(vue.version) === 2) {
7577
// for Vue 2 projects
7678
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', {
7779
'vue-loader': require('vue-loader/package.json').version,
@@ -106,7 +108,7 @@ module.exports = (api, options) => {
106108
webpackConfig
107109
.plugin('vue-loader')
108110
.use(require('vue-loader').VueLoaderPlugin)
109-
} else if (semver.major(vue.version) === 3) {
111+
} else if (vue && semver.major(vue.version) === 3) {
110112
// for Vue 3 projects
111113
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', {
112114
'vue-loader': require('vue-loader-v16/package.json').version,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.