Skip to content

Commit 353d590

Browse files
committed
Add a fix for the build
1 parent 7866aaf commit 353d590

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

.github/workflows/preview.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
npm run build
3434
env:
3535
BASE_URL: /pr-${{github.event.number}}
36+
NODE_ENV: production
3637
- name: Upload artifact
3738
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
3839
with:

hugo/scripts/build.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
1-
import cp from 'child_process';
2-
import { dirname, resolve } from 'path';
1+
import { execSync, spawnSync } from "child_process";
2+
import { dirname, resolve } from "path";
33

44
const baseUrl = getBaseUrl();
55
console.log(`Building website for location '${baseUrl}'...`);
66
performHugoBuild(baseUrl);
77

88
function getBaseUrl() {
9-
return process.env['BASE_URL'] || '/';
9+
return process.env["BASE_URL"] || "/";
1010
}
1111

1212
function performHugoBuild(rootDir) {
13-
const executable = resolve(dirname(process.execPath), 'npm');
14-
cp.spawnSync(executable, [
15-
'exec',
16-
'--', 'hugo',
17-
'--config', 'config.toml',
18-
'-b', rootDir,
19-
'-d', '../public',
20-
'--gc',
21-
'--minify'
22-
], {
23-
env: {
24-
NODE_ENV: "production"
25-
},
26-
shell: true,
27-
stdio: 'inherit'
28-
});
29-
}
13+
const executable = resolve(dirname(process.execPath), "npx");
14+
spawnSync(executable, ["hugo", "--config", "config.toml", "-b", rootDir, "-d", "../public", "--gc", "--minify"], {
15+
shell: true,
16+
stdio: "inherit",
17+
});
18+
}

0 commit comments

Comments
 (0)