Compile multiple submodules in a requirejs build

81 Views Asked by At

I have a relatively unique requirejs structure for a game I'm getting started on. The current code is just my start, but I was trying to figure out how to build it as a single javascript file, probably with optimizations as well.

The problem I'm running into is that I've set up the engine module to have submodules for each part of the engine. The idea behind this is that it's easy to drop in different engine modules, and have their own configurations if needed. Currently I'm not taking advantage of this feature, but I may in the future, so would like to not have to work around it if possible.

Here's an idea of the tree:

game - root directory for game code
- main.js - primary application definition
- engine - engine module
- - main.js - engine module definition
- - audio - audio module
- - ...
- - scene - scene module

I have all of the submodules that make up engine as relative paths, so the engine can get moved around without having to update where it should look for it's submodules. The problem with this is that when building with node, it doesn't seem to read the require.config() settings in the engine module, causing it to look for it's submodules in places that don't exist.

I'm sure my structure is wrong, but any ideas on how I can preserve my way of separating my engine modules while being able to build my entire game structure into a single file would be greatly appreciated.

You can see the specifics in the GitHub repo: https://github.com/RedShiftDev/project-helium

0

There are 0 best solutions below