diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 58091abf..f6d3448b 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -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: diff --git a/hugo/scripts/build.js b/hugo/scripts/build.js index 6252d479..4c78fb11 100755 --- a/hugo/scripts/build.js +++ b/hugo/scripts/build.js @@ -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' - }); -} \ No newline at end of file + const executable = resolve(dirname(process.execPath), "npx"); + spawnSync(executable, ["hugo", "--config", "config.toml", "-b", rootDir, "-d", "../public", "--gc", "--minify"], { + shell: true, + stdio: "inherit", + }); +}