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

Commit b75d44d

Browse files
committed
fix(build): add publicPath to fileServer
1 parent 1c7df72 commit b75d44d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/fusuma/src/tasks/build.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { build: webpackBuild } = require('../webpack');
77
const deleteDir = require('../utils/deleteDir');
88
const fileServer = require('../utils/fileServer');
99

10-
async function createOgImage(outputDirPath) {
10+
async function createOgImage(outputDirPath, publicPath) {
1111
const puppeteer = require('puppeteer');
1212

1313
const port = 5445;
@@ -23,7 +23,7 @@ async function createOgImage(outputDirPath) {
2323
width: 1200,
2424
height: 630,
2525
});
26-
const app = await fileServer(outputDirPath, port);
26+
const app = await fileServer(outputDirPath, publicPath, port);
2727
await page.goto(`http://localhost:${port}?sidebar=false`, {
2828
waitUntil: ['load', 'networkidle2'],
2929
});
@@ -44,7 +44,7 @@ async function build(config, isConsoleOutput = true) {
4444
process.env.NODE_ENV = 'production';
4545
}
4646

47-
await deleteDir(outputDirPath);
47+
await deleteDir(outputDirPath, config.build.publicPath);
4848
await webpackBuild(config, isConsoleOutput, (type) => {
4949
if (type == 'start-build') {
5050
spinner.color = 'yellow';

packages/fusuma/src/utils/fileServer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
const express = require('express');
44

5-
async function fileServer(basePath, port = 5445) {
5+
async function fileServer(basePath, publicPath, port = 5445) {
66
return new Promise((resolve, reject) => {
77
const app = express();
88

99
app.use(express.static(basePath));
10+
app.use(`/${publicPath}`, express.static(basePath));
1011

1112
const server = app.listen(port, (err) => {
1213
if (err) {

0 commit comments

Comments
 (0)