@@ -36,6 +36,7 @@ define(function (require, exports, module) {
3636 EventDispatcher = require ( "utils/EventDispatcher" ) ,
3737 CommandManager = require ( "command/CommandManager" ) ,
3838 Commands = require ( "command/Commands" ) ,
39+ StringUtils = require ( "utils/StringUtils" ) ,
3940 EventManager = require ( "utils/EventManager" ) ,
4041 LivePreviewSettings = require ( "./LivePreviewSettings" ) ,
4142 ProjectManager = require ( "project/ProjectManager" ) ,
@@ -112,10 +113,13 @@ define(function (require, exports, module) {
112113 encodeURIComponent ( `${ Strings . DESCRIPTION_LIVEDEV_MAIN_SPAN } ` ) ;
113114 }
114115
115- function getNoPreviewURL ( ) {
116+ function getNoPreviewURL (
117+ heading = Strings . DESCRIPTION_LIVEDEV_NO_PREVIEW ,
118+ message = Strings . DESCRIPTION_LIVEDEV_NO_PREVIEW_DETAILS
119+ ) {
116120 return `${ window . Phoenix . baseURL } assets/phoenix-splash/no-preview.html?jsonInput=` +
117- encodeURIComponent ( `{"heading":"${ Strings . DESCRIPTION_LIVEDEV_NO_PREVIEW } ",`
118- + `"details":"${ Strings . DESCRIPTION_LIVEDEV_NO_PREVIEW_DETAILS } "}` ) ;
121+ encodeURIComponent ( `{"heading":"${ heading } ",`
122+ + `"details":"${ message } "}` ) ;
119123 }
120124
121125 function _isLivePreviewSupported ( ) {
@@ -153,6 +157,7 @@ define(function (require, exports, module) {
153157 httpFilePath = fullPath ;
154158 }
155159 const customServeURL = LivePreviewSettings . getCustomServerConfig ( fullPath ) ;
160+ const shouldUseInbuiltPreview = utils . isMarkdownFile ( fullPath ) || utils . isSVG ( fullPath ) ;
156161 if ( customServeURL ) {
157162 const relativePath = path . relative ( projectRoot , fullPath ) ;
158163 resolve ( {
@@ -165,7 +170,17 @@ define(function (require, exports, module) {
165170 serverSupportsHotReload : LivePreviewSettings . serverSupportsHotReload ( )
166171 } ) ;
167172 return ;
168- } else if ( utils . isPreviewableFile ( fullPath ) ) {
173+ } else if ( LivePreviewSettings . isUsingCustomServer ( ) && ! customServeURL && ! shouldUseInbuiltPreview ) {
174+ // this is the case where the file is outside of a custom configured server root (E. `www/`)
175+ // like `notServed/Path.html`. For markdown and SVG, we will still use the inbuilt live preview.
176+ resolve ( {
177+ URL : getNoPreviewURL ( Strings . DESCRIPTION_LIVEDEV_EXCLUDED ,
178+ StringUtils . format ( Strings . DESCRIPTION_LIVEDEV_NO_PREVIEW_EXCLUDED ,
179+ LivePreviewSettings . getCustomServeRoot ( ) ) ) ,
180+ isNoPreview : true
181+ } ) ;
182+ return ;
183+ } else if ( utils . isPreviewableFile ( fullPath ) ) {
169184 const filePath = httpFilePath || path . relative ( projectRoot , fullPath ) ;
170185 let URL = httpFilePath || `${ projectRootUrl } ${ filePath } ` ;
171186 resolve ( {
0 commit comments