Skip to content

Commit

Permalink
Add a fix for the build
Browse files Browse the repository at this point in the history
  • Loading branch information
Lotes committed Aug 22, 2024
1 parent cd9f42a commit 0cef447
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
npm run build
env:
BASE_URL: /pr-${{github.event.number}}
NODE_ENV: production
- name: Upload artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
Expand Down
29 changes: 9 additions & 20 deletions hugo/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import cp from 'child_process';
import { dirname, resolve } from 'path';
import { execSync, spawnSync } from "child_process";
import { dirname, resolve } from "path";

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

function getBaseUrl() {
return process.env['BASE_URL'] || '/';
return process.env["BASE_URL"] || "/";
}

function performHugoBuild(rootDir) {
const executable = resolve(dirname(process.execPath), 'npm');
cp.spawnSync(executable, [
'exec',
'--', 'hugo',
'--config', 'config.toml',
'-b', rootDir,
'-d', '../public',
'--gc',
'--minify'
], {
env: {
NODE_ENV: "production"
},
shell: true,
stdio: 'inherit'
});
}
const executable = resolve(dirname(process.execPath), "npx");
spawnSync(executable, ["hugo", "--config", "config.toml", "-b", rootDir, "-d", "../public", "--gc", "--minify"], {
shell: true,
stdio: "inherit",
});
}

0 comments on commit 0cef447

Please sign in to comment.