Browse Source

replaced absolute paths to resources with relative

this allows the release build files in 'dist' to be copied over into
a static folder for the indy.io hugo site
master
Inderjit Gill 1 year ago
parent
commit
1f1fd854f9
4 changed files with 20 additions and 16 deletions
  1. +3
    -2
      package.json
  2. +9
    -6
      serve.go
  3. +7
    -7
      web/js/Audio.js
  4. +1
    -1
      web/js/index.js

+ 3
- 2
package.json View File

@@ -4,13 +4,14 @@
"serve:release": "serve",
"build:dev": "webpack --mode=development --progress",
"build:dev:wasm": "cargo +nightly build --target wasm32-unknown-unknown && wasm-bindgen target/wasm32-unknown-unknown/debug/wasm_tetris.wasm --out-dir web",
"build:release": "cargo +nightly build --release --target wasm32-unknown-unknown && wasm-bindgen target/wasm32-unknown-unknown/release/wasm_tetris.wasm --out-dir web && webpack --mode=production --progress && cp index.html dist/index.html",
"build:release": "cargo +nightly build --release --target wasm32-unknown-unknown && wasm-bindgen target/wasm32-unknown-unknown/release/wasm_tetris.wasm --out-dir web && webpack --mode=production --progress && cp index.html dist/index.html && mkdirp dist/web && cp -r web/img dist/web/img && cp -r web/sfx dist/web/sfx",
"build:server": "go build serve.go"
},
"devDependencies": {
"webpack": "4.16.1",
"webpack-cli": "3.1.0",
"webpack-dev-server": "3.1.4"
"webpack-dev-server": "3.1.4",
"mkdirp": "0.5.1"
},
"dependencies": {
"howler": "2.0.14"

+ 9
- 6
serve.go View File

@@ -7,8 +7,14 @@ import (
)

/*
serve web file from: /web (for images used as textures)
serve everything else from: /dist (generated with npm run build:prod)
build this file once:
$ go build serve.go

build the release version with:
$ npm run build:release

serve everything from /dist with:
$ ./serve
*/

var wasmFile = regexp.MustCompile("\\.wasm$")
@@ -27,10 +33,7 @@ func maxAgeHandler(seconds int, h http.Handler) http.Handler {
}

func main() {
fs := http.FileServer(http.Dir("web"))
http.Handle("/web/", http.StripPrefix("/web/", fs))

fs = http.FileServer(http.Dir("dist"))
fs := http.FileServer(http.Dir("dist"))
http.Handle("/", maxAgeHandler(0, fs))

fmt.Printf("Serving localhost:3000\n")

+ 7
- 7
web/js/Audio.js View File

@@ -3,25 +3,25 @@ import { Howl, Howler } from "howler";
export class Audio {
constructor(config) {
this.game_over = new Howl({
src: ['/web/sfx/negative1.mp3']
src: ['web/sfx/negative1.mp3']
});
this.line1 = new Howl({
src: ['/web/sfx/fanfare1.mp3']
src: ['web/sfx/fanfare1.mp3']
});
this.line2 = new Howl({
src: ['/web/sfx/fanfare1.mp3']
src: ['web/sfx/fanfare1.mp3']
});
this.line3 = new Howl({
src: ['/web/sfx/fanfare2.mp3']
src: ['web/sfx/fanfare2.mp3']
});
this.line4 = new Howl({
src: ['/web/sfx/fanfare3.mp3']
src: ['web/sfx/fanfare3.mp3']
});
this.pause_in = new Howl({
src: ['/web/sfx/pause2_in.mp3']
src: ['web/sfx/pause2_in.mp3']
});
this.pause_out = new Howl({
src: ['/web/sfx/pause2_out.mp3']
src: ['web/sfx/pause2_out.mp3']
});
}


+ 1
- 1
web/js/index.js View File

@@ -8,7 +8,7 @@ let gState = {

config: new Config(),

tileset: '/web/img/tileset.png',
tileset: 'web/img/tileset.png',

bridge: undefined,
animationId: undefined,

Loading…
Cancel
Save