Skip to content

Commit

Permalink
Try with build.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Lotes committed Aug 22, 2024
1 parent 2ebb312 commit 7866aaf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ jobs:
- name: Build
run: |
npm install
./hugo/scripts/build.sh production "/pr-${{github.event.number}}"
npm run build
env:
BASE_URL: /pr-${{github.event.number}}
- name: Upload artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
Expand Down
2 changes: 1 addition & 1 deletion hugo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build:worker/sql": "esbuild ./assets/scripts/sql/language-server.ts --bundle --format=iife --outfile=./static/showcase/libs/worker/sqlServerWorker.js",
"build:worker/minilogo": "esbuild ../node_modules/langium-minilogo/out/language-server/main-browser.js --bundle --format=iife --outfile=./static/showcase/libs/worker/minilogoServerWorker.js",
"build:static": "npm run clean:static && npm run build:worker/statemachine && npm run build:worker/domainmodel && npm run build:worker/sql && npm run build:worker/minilogo && npm run build:worker/arithmetics && npm run build:worker/playground-common && npm run build:worker/playground-langium && npm run build:worker/playground-user && npm run copy:monaco-workers",
"build": "./scripts/build.sh production /",
"build": "npm run build:static && node ./scripts/build.js",
"watch": "npm run build:static && cross-env NODE_ENV=development hugo server --config ./config.toml -D -b localhost:1313 -d ../public --appendPort=false",
"watch:gitpod": "npm run build:static && cross-env NODE_ENV=development hugo server --config ./config.toml -D -b `gp url 1313` -d ../public --appendPort=false"
},
Expand Down
29 changes: 29 additions & 0 deletions hugo/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import cp 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'] || '/';
}

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'
});
}
3 changes: 0 additions & 3 deletions hugo/scripts/build.sh

This file was deleted.

0 comments on commit 7866aaf

Please sign in to comment.