Skip to content

Commit 96eab19

Browse files
committed
Improved mounting
1 parent 33c671e commit 96eab19

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

fiveserver.config.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ module.exports = {
99
// browser: ['C:\\Program Files\\Firefox Developer Edition\\firefox.exe --private-window'],
1010
watch: 'dev',
1111
ignore: [/\.s[ac]ss$/i, /\.tsx?$/i],
12+
// mount: [['/img', 'C:\\Users\\USERNAME\\Pictures']],
1213
remoteLogs: 'brightMagenta'
14+
// logLevel: 2
1315
}

src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,16 @@ export default class LiveServer {
212212
mount.forEach(mountRule => {
213213
const mountPath = path.resolve(process.cwd(), mountRule[1])
214214
if (!options.watch)
215-
// Auto add mount paths to wathing but only if exclusive path option is not given
215+
// Auto add mount paths to watching but only if exclusive path option is not given
216216
watchPaths.push(mountPath)
217-
app.use(mountRule[0], staticServer(mountPath, { logLevel, injectedCode: INJECTED_CODE }))
217+
218+
// make sure mountRule[0] has a leading slash
219+
if (mountRule[0].indexOf('/') !== 0) mountRule[0] = `/${mountRule[0]}`
220+
221+
// mount it with express.static
222+
app.use(mountRule[0], express.static(mountPath))
223+
224+
// log the mapping folder
218225
if (this.logLevel >= 1) console.log('Mapping %s to "%s"', mountRule[0], mountPath)
219226
})
220227
proxy.forEach(proxyRule => {

0 commit comments

Comments
 (0)