@@ -24,7 +24,7 @@ function encode (obj) {
24
24
25
25
function formatPublicPath ( path ) {
26
26
if ( ! path ) {
27
- return path
27
+ return path || ''
28
28
}
29
29
30
30
if ( ! path . endsWith ( '/' ) ) {
@@ -477,14 +477,10 @@ class QuasarConfig {
477
477
cfg . build . publicPath =
478
478
( this . ctx . prod || cfg . build . forceDevPublicPath ) && cfg . build . publicPath && [ 'spa' , 'pwa' ] . includes ( this . ctx . modeName )
479
479
? formatPublicPath ( cfg . build . publicPath )
480
- : ( cfg . build . vueRouterMode !== 'hash' ? '/ ' : '' )
480
+ : ( cfg . build . vueRouterMode === 'hash' ? '' : '/ ' )
481
481
482
482
cfg . build . vueRouterBase = formatRouterBase ( cfg . build . publicPath )
483
483
484
- cfg . build . appBase = cfg . build . vueRouterMode === 'history'
485
- ? cfg . build . publicPath
486
- : ''
487
-
488
484
cfg . sourceFiles = merge ( {
489
485
rootComponent : 'src/App.vue' ,
490
486
router : 'src/router/index' ,
@@ -539,6 +535,8 @@ class QuasarConfig {
539
535
}
540
536
541
537
if ( this . ctx . dev ) {
538
+ const originalBefore = cfg . devServer . before
539
+
542
540
cfg . devServer = merge ( {
543
541
publicPath : cfg . build . publicPath ,
544
542
hot : true ,
@@ -551,26 +549,34 @@ class QuasarConfig {
551
549
compress : true ,
552
550
open : true
553
551
} , cfg . devServer , {
554
- contentBase : [ appPaths . srcDir ]
552
+ contentBase : false ,
553
+
554
+ before : app => {
555
+ if ( ! this . ctx . mode . ssr ) {
556
+ const express = require ( 'express' )
557
+
558
+ app . use ( ( cfg . build . publicPath || '/' ) + 'statics' , express . static ( appPaths . resolve . src ( 'statics' ) , {
559
+ maxAge : 0
560
+ } ) )
561
+
562
+ if ( this . ctx . mode . cordova ) {
563
+ const folder = appPaths . resolve . cordova ( `platforms/${ this . ctx . targetName } /platform_www` )
564
+ app . use ( '/' , express . static ( folder , { maxAge : 0 } ) )
565
+ }
566
+ }
567
+
568
+ originalBefore && originalBefore ( app )
569
+ }
555
570
} )
556
571
557
- if ( this . ctx . mode . ssr ) {
558
- cfg . devServer . contentBase = false
559
- }
560
- else if ( this . ctx . mode . cordova || this . ctx . mode . electron ) {
572
+ if ( this . ctx . mode . cordova || this . ctx . mode . electron ) {
561
573
cfg . devServer . open = false
562
574
563
575
if ( this . ctx . mode . electron ) {
564
576
cfg . devServer . https = false
565
577
}
566
578
}
567
579
568
- if ( this . ctx . mode . cordova ) {
569
- cfg . devServer . contentBase . push (
570
- appPaths . resolve . cordova ( `platforms/${ this . ctx . targetName } /platform_www` )
571
- )
572
- }
573
-
574
580
if ( cfg . devServer . open ) {
575
581
const isMinimalTerminal = require ( './helpers/is-minimal-terminal' )
576
582
if ( isMinimalTerminal ) {
@@ -682,8 +688,12 @@ class QuasarConfig {
682
688
const host = cfg . devServer . host === '0.0.0.0'
683
689
? 'localhost'
684
690
: cfg . devServer . host
685
- const urlPath = `${ cfg . build . vueRouterMode === 'hash' ? ( cfg . build . htmlFilename !== 'index.html' ? cfg . build . htmlFilename : '' ) : '' } `
686
- cfg . build . APP_URL = `http${ cfg . devServer . https ? 's' : '' } ://${ host } :${ cfg . devServer . port } /${ urlPath } `
691
+
692
+ const urlPath = cfg . build . vueRouterMode === 'hash'
693
+ ? ( cfg . build . htmlFilename !== 'index.html' ? ( cfg . build . publicPath ? '' : '/' ) + cfg . build . htmlFilename : '' )
694
+ : ''
695
+
696
+ cfg . build . APP_URL = `http${ cfg . devServer . https ? 's' : '' } ://${ host } :${ cfg . devServer . port } ${ cfg . build . publicPath } ${ urlPath } `
687
697
}
688
698
else if ( this . ctx . mode . cordova ) {
689
699
cfg . build . APP_URL = 'index.html'
@@ -706,13 +716,8 @@ class QuasarConfig {
706
716
'process.env' : cfg . build . env
707
717
}
708
718
709
- if ( this . ctx . mode . electron ) {
710
- if ( this . ctx . dev ) {
711
- cfg . build . env . __statics = `"${ appPaths . resolve . src ( 'statics' ) . replace ( / \\ / g, '\\\\' ) } "`
712
- }
713
- }
714
- else {
715
- cfg . build . env . __statics = `"${ ( ( this . ctx . prod || cfg . build . forceDevPublicPath ) && cfg . build . publicPath ) ? cfg . build . publicPath : '/' } statics"`
719
+ if ( this . ctx . mode . electron && this . ctx . dev ) {
720
+ cfg . build . env . __statics = `"${ appPaths . resolve . src ( 'statics' ) . replace ( / \\ / g, '\\\\' ) } "`
716
721
}
717
722
718
723
appFilesValidations ( cfg )
0 commit comments