Gaweph / p5-typescript-starter

Base starter project using p5js and typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Routing to mulitple Sketches

danobot opened this issue · comments

Thanks for making this boileplate, it has helped me heaps in my p5 learning journey already.
How would you add URL routing such that multiple sketches can be developed in this repository? It's a common use case to work on different independent sketches and I'd like to take advantage of all the nice features such as typescript and automatic browser reloads that this setup has to offer.

I want to be able to work on different sketches and access them using URls like:

http://localhost:3000/sketch1
http://localhost:3000/sketch2

Ideally, the compiler should exclude files that are not relevant to the requested sketch to keep compile and load times fast.

I control this using the files section of tsconfig.json:

{
    "compilerOptions": {
        ...
        "rootDir": "./sketch/",
        "outFile": "./build/sketch.js"
    },
    "files": [
        "global.d.ts",
        "sketch/the-sketch-i-want.ts"
    ]
}

Then when you want to try another sketch just change the name of that last line...

thanks! thats exactly what I'm looking for