File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
packages/@vue/cli-service/lib Expand file tree Collapse file tree 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) => {
123123 webpackConfig
124124 . plugin ( 'html' )
125125 . 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+ )
127131 ] )
128132
129133 webpackConfig
Original file line number Diff line number Diff line change 11const prefixRE = / ^ V U E _ A P P _ /
22
3- module . exports = function resolveClientEnv ( publicPath ) {
3+ module . exports = function resolveClientEnv ( publicPath , raw ) {
44 const env = { }
55 Object . keys ( process . env ) . forEach ( key => {
66 if ( prefixRE . test ( key ) || key === 'NODE_ENV' ) {
7- env [ key ] = JSON . stringify ( process . env [ key ] )
7+ env [ key ] = process . env [ key ]
88 }
99 } )
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+ }
1119 return {
1220 'process.env' : env
1321 }
You can’t perform that action at this time.
0 commit comments