Skip to content

Commit ddf9c36

Browse files
committed
refactor: consistent build target env variable
1 parent 3a68139 commit ddf9c36

File tree

5 files changed

+5
-8
lines changed

5 files changed

+5
-8
lines changed

packages/@vue/babel-preset-app/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = (context, options = {}) => {
5959
// useBuiltIns: 'usage' we won't be running Babel on these deps, they need to
6060
// be force-included.
6161
let polyfills
62-
const buildTarget = process.env.VUE_CLI_TARGET || 'app'
62+
const buildTarget = process.env.VUE_CLI_BUILD_TARGET || 'app'
6363
if (
6464
buildTarget === 'app' &&
6565
useBuiltIns === 'usage' &&

packages/@vue/cli-service/lib/commands/build/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = (api, options) => {
4343
args.entry = args.entry || 'src/App.vue'
4444
}
4545

46+
process.env.VUE_CLI_BUILD_TARGET = args.target
4647
if (args.modern && args.target === 'app') {
4748
process.env.VUE_CLI_MODERN_MODE = true
4849
delete process.env.VUE_CLI_MODERN_BUILD
@@ -59,8 +60,9 @@ module.exports = (api, options) => {
5960
delete process.env.VUE_CLI_MODERN_MODE
6061
delete process.env.VUE_CLI_MODERN_BUILD
6162
} else {
62-
return build(args, api, options)
63+
await build(args, api, options)
6364
}
65+
delete process.env.VUE_CLI_BUILD_TARGET
6466
})
6567
}
6668

@@ -100,7 +102,6 @@ async function build (args, api, options) {
100102
const isLegacyBuild = args.target === 'app' && args.modern && !args.modernBuild
101103

102104
// resolve raw webpack config
103-
process.env.VUE_CLI_BUILD_TARGET = args.target
104105
let webpackConfig
105106
if (args.target === 'lib') {
106107
webpackConfig = require('./resolveLibConfig')(api, args, options)

packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ const fs = require('fs')
22
const path = require('path')
33

44
module.exports = (api, { entry, name }, options) => {
5-
// setting this disables app-only configs
6-
process.env.VUE_CLI_TARGET = 'lib'
75
// inline all static asset files since there is no publicPath handling
86
process.env.VUE_CLI_INLINE_LIMIT = Infinity
97

packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ const path = require('path')
22
const { resolveEntry, fileToComponentName } = require('./resolveWcEntry')
33

44
module.exports = (api, { target, entry, name }) => {
5-
// setting this disables app-only configs
6-
process.env.VUE_CLI_TARGET = 'web-component'
75
// Disable CSS extraction and turn on CSS shadow mode for vue-style-loader
86
process.env.VUE_CLI_CSS_SHADOW_MODE = true
97

packages/@vue/cli-service/lib/config/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const path = require('path')
55
module.exports = (api, options) => {
66
api.chainWebpack(webpackConfig => {
77
// only apply when there's no alternative target
8-
if (process.env.VUE_CLI_TARGET) {
8+
if (process.env.VUE_CLI_BUILD_TARGET && process.env.VUE_CLI_BUILD_TARGET !== 'app') {
99
return
1010
}
1111

0 commit comments

Comments
 (0)