Skip to content

Commit 96e5f81

Browse files
committed
fix: make assets optional
1 parent 4bf4af0 commit 96e5f81

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export function build({
6262

6363
fs.writeFileSync(path.join(output, 'app.src.js'), buildEntry({ layout }));
6464
fs.writeFileSync(path.join(output, 'app.data.js'), stringifyData(data));
65-
fs.copySync(assets, path.join(output, 'assets'));
65+
66+
assets && fs.copySync(assets, path.join(output, 'assets'));
6667

6768
buildEntry({ layout });
6869
buildPageInfo(data).forEach(info => {
@@ -140,8 +141,12 @@ export function serve({
140141

141142
const app = express();
142143

143-
app.get('/assets/*', (req, res) => {
144-
res.sendFile(path.join(assets, req.path.replace(/^\/assets\//, '')));
144+
app.get('/assets/*', (req, res, next) => {
145+
if (assets) {
146+
res.sendFile(path.join(assets, req.path.replace(/^\/assets\//, '')));
147+
} else {
148+
next();
149+
}
145150
});
146151

147152
app.get('*', (req, res, next) => {

src/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type Page =
1010
export type Separator = { type: 'separator' };
1111

1212
export type Options = {
13-
assets: string,
13+
assets?: string,
1414
pages: Array<Page | Separator> | (() => Array<Page | Separator>),
1515
output: string,
1616
port?: number,

0 commit comments

Comments
 (0)