Skip to content

Commit 4c69052

Browse files
author
Guillaume Chau
committed
fix(ui): wrong context for webpack config, closes 1611
1 parent 6c8d220 commit 4c69052

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

packages/@vue/cli-ui/src/graphql-api/connectors/plugins.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const {
88
getPluginLink
99
} = require('@vue/cli-shared-utils')
1010
const getPackageVersion = require('@vue/cli/lib/util/getPackageVersion')
11-
const { resolveModule, loadModule } = require('@vue/cli/lib/util/module')
11+
const { resolveModule, loadModule, clearModule } = require('@vue/cli/lib/util/module')
1212
const {
1313
progress: installProgress,
1414
installPackage,
@@ -340,6 +340,9 @@ function runInvoke (id, context) {
340340
status: 'plugin-invoke',
341341
args: [id]
342342
})
343+
344+
clearModule('@vue/cli-service/webpack.config.js', cwd.get())
345+
343346
currentPluginId = id
344347
// Allow plugins that don't have a generator
345348
if (resolveModule(`${id}/generator`, cwd.get())) {

packages/@vue/cli-ui/src/graphql-api/connectors/projects.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { getFeatures } = require('@vue/cli/lib/util/features')
77
const { defaults } = require('@vue/cli/lib/options')
88
const { toShortPluginId } = require('@vue/cli-shared-utils')
99
const { progress: installProgress } = require('@vue/cli/lib/util/installDeps')
10+
const { clearModule } = require('@vue/cli/lib/util/module')
1011
// Connectors
1112
const progress = require('./progress')
1213
const cwd = require('./cwd')
@@ -250,6 +251,9 @@ async function create (input, context) {
250251
cwd.set(targetDir, context)
251252
creator.context = targetDir
252253

254+
process.env.VUE_CLI_CONTEXT = targetDir
255+
clearModule('@vue/cli-service/webpack.config.js', targetDir)
256+
253257
const inCurrent = input.folder === '.'
254258
const name = inCurrent ? path.relative('../', process.cwd()) : input.folder
255259
creator.name = name

packages/@vue/cli/lib/util/module.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ exports.loadModule = function (request, context, force = false) {
5252
}
5353
}
5454

55+
exports.clearModule = function (request, context) {
56+
const resolvedPath = exports.resolveModule(request, context)
57+
if (resolvedPath) {
58+
clearRequireCache(resolvedPath)
59+
}
60+
}
61+
5562
function clearRequireCache (id, map = new Map()) {
5663
const module = require.cache[id]
5764
if (module) {

0 commit comments

Comments
 (0)