Skip to content

Allow relative path for VUE_CLI_CONTEXT #3548

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/@vue/cli-service/bin/vue-cli-service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

const path = require('path')
const semver = require('semver')
const { error } = require('@vue/cli-shared-utils')
const requiredVersion = require('../package.json').engines.node
Expand All @@ -12,8 +13,13 @@ if (!semver.satisfies(process.version, requiredVersion)) {
process.exit(1)
}

let vueCliContext = process.env.VUE_CLI_CONTEXT
if (vueCliContext && !path.isAbsolute(vueCliContext)) {
vueCliContext = path.resolve(process.cwd(), vueCliContext)
}

const Service = require('../lib/Service')
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd())
const service = new Service(vueCliContext || process.cwd())

const rawArgv = process.argv.slice(2)
const args = require('minimist')(rawArgv, {
Expand Down
7 changes: 6 additions & 1 deletion packages/@vue/cli-service/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
// this file is for cases where we need to access the
// webpack config as a file when using CLI commands.
const path = require('path')

let vueCliContext = process.env.VUE_CLI_CONTEXT
let service = process.VUE_CLI_SERVICE

if (!service || process.env.VUE_CLI_API_MODE) {
const Service = require('./lib/Service')
service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd())
if (vueCliContext && !path.isAbsolute(vueCliContext)) {
vueCliContext = path.resolve(process.cwd(), vueCliContext)
}
service = new Service(vueCliContext || process.cwd())
service.init(process.env.VUE_CLI_MODE || process.env.NODE_ENV)
}

Expand Down