Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit e18508d

Browse files
committed
feat(start): add -f option to serve dist directory
1 parent 99ac808 commit e18508d

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

packages/fusuma/src/cli/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ async function cli() {
2828
.option('-b <directory>', 'A base path', prog.STRING, process.cwd())
2929
.option('-i <directory>', 'A directory to load', prog.STRING, 'slides')
3030
.option('-p <port>', 'Dev server port', prog.INT, '8080')
31+
.option('-f <fileMode>', 'A serve for a bundled directory', prog.BOOLEAN, false)
3132
.action((args, options) => {
3233
resolve({
3334
type: 'start',
3435
options: {
3536
basePath: options.b,
3637
inputDir: options.i,
3738
port: options.p,
39+
isFileServer: options.f,
3840
},
3941
});
4042
})

packages/fusuma/src/tasks/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ async function tasks({ type, options }) {
3939
internal: { ...options, basePath, inputDirPath, outputDirPath },
4040
});
4141

42+
if (options.isFileServer) {
43+
return require('./serverFilesForProd')(config);
44+
}
45+
4246
switch (type) {
4347
case 'init':
4448
return require('./init')(config);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
const server = require('../server/fileServer');
4+
const { info } = require('../cli/log');
5+
6+
async function serverFilesForProd(config) {
7+
await server(config.internal.outputDirPath, config.build.publicPath, config.internal.port);
8+
info('start', `Serving on http://localhost:${config.internal.port}`);
9+
}
10+
11+
module.exports = serverFilesForProd;

samples/intro/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"init": "FUSUMA_DEBUG=true node ../../packages/fusuma/src/cli init",
88
"start": "FUSUMA_DEBUG=true node ../../packages/fusuma/src/cli start",
9+
"start:prod": "FUSUMA_DEBUG=true node ../../packages/fusuma/src/cli start -f true",
910
"build": "FUSUMA_DEBUG=true node ../../packages/fusuma/src/cli build",
1011
"pdf": "FUSUMA_DEBUG=true node ../../packages/fusuma/src/cli pdf",
1112
"live": "FUSUMA_DEBUG=true node ../../packages/fusuma/src/cli live -w '@nodejs'",

0 commit comments

Comments
 (0)