File tree 2 files changed +16
-4
lines changed
packages/@vue/cli-service/lib
2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,11 @@ module.exports = (api, options) => {
123
123
webpackConfig
124
124
. plugin ( 'html' )
125
125
. use ( require ( 'html-webpack-plugin' ) , [
126
- fs . existsSync ( htmlPath ) ? { template : htmlPath } : { }
126
+ Object . assign (
127
+ fs . existsSync ( htmlPath ) ? { template : htmlPath } : { } ,
128
+ // expose client env to html template
129
+ { env : resolveClientEnv ( options . baseUrl , true /* raw */ ) }
130
+ )
127
131
] )
128
132
129
133
webpackConfig
Original file line number Diff line number Diff line change 1
1
const prefixRE = / ^ V U E _ A P P _ /
2
2
3
- module . exports = function resolveClientEnv ( publicPath ) {
3
+ module . exports = function resolveClientEnv ( publicPath , raw ) {
4
4
const env = { }
5
5
Object . keys ( process . env ) . forEach ( key => {
6
6
if ( prefixRE . test ( key ) || key === 'NODE_ENV' ) {
7
- env [ key ] = JSON . stringify ( process . env [ key ] )
7
+ env [ key ] = process . env [ key ]
8
8
}
9
9
} )
10
- env . BASE_URL = JSON . stringify ( publicPath )
10
+ env . BASE_URL = publicPath
11
+
12
+ if ( raw ) {
13
+ return env
14
+ }
15
+
16
+ for ( const key in env ) {
17
+ env [ key ] = JSON . stringify ( env [ key ] )
18
+ }
11
19
return {
12
20
'process.env' : env
13
21
}
You can’t perform that action at this time.
0 commit comments