Move static outside HTML. Start work on TypeScript bundle
It's not strictly HTML, so that's just correct. This is just worth doing while building the new TypeScript bundle
This commit is contained in:
parent
976a29b7d7
commit
31947c848a
53 changed files with 7100 additions and 73 deletions
29
default.nix
29
default.nix
|
|
@ -12,10 +12,14 @@ pkgs.buildGoModule rec {
|
|||
vendorHash = "sha256-zXjryPAJYpc80cqYtrcp//i6OQi5V5QwhaKQYYfrlL8=";
|
||||
|
||||
buildInputs = [ pkgs.proj ];
|
||||
nativeBuildInputs = [ pkgs.pkg-config pkgs.dart-sass ];
|
||||
nativeBuildInputs = [
|
||||
pkgs.pkg-config
|
||||
pkgs.dart-sass
|
||||
pkgs.esbuild
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
|
||||
# Compile SCSS
|
||||
SASS_SRC_DIR="./scss"
|
||||
CSS_OUTPUT_DIR="./html/static/css/"
|
||||
|
||||
|
|
@ -23,5 +27,26 @@ pkgs.buildGoModule rec {
|
|||
|
||||
echo "Compiling $SASS_SRC_DIR/custom.scss to $CSS_OUTPUT_DIR/bootstrap.css..."
|
||||
sass --style=compressed --trace "$SASS_SRC_DIR/custom.scss":"$CSS_OUTPUT_DIR/bootstrap.css"
|
||||
|
||||
# Bundle TypeScript
|
||||
JS_OUTPUT_DIR="./html/static/gen/js/"
|
||||
mkdir -p "$JS_OUTPUT_DIR"
|
||||
|
||||
echo "Bundling TypeScript..."
|
||||
esbuild ts/main.ts --bundle --minify --outfile="$JS_OUTPUT_DIR/bundle.js"
|
||||
|
||||
# Generate hash and rename bundle
|
||||
BUNDLE_HASH=$(sha256sum "$JS_OUTPUT_DIR/bundle.js" | cut -c1-12)
|
||||
mv "$JS_OUTPUT_DIR/bundle.js" "$JS_OUTPUT_DIR/bundle.$BUNDLE_HASH.js"
|
||||
|
||||
# Generate gen.go with bundle path
|
||||
cat > gen.go <<EOF
|
||||
package main
|
||||
|
||||
// Generated by Nix build - do not edit manually
|
||||
const JsBundlePath = "/static/js/bundel.$BUNDLE_HASH.js"
|
||||
EOF
|
||||
|
||||
echo "Generated JS bundle with hash: $BUNDLE_HASH"
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue