Build used as node module


what is the recommended workflow for builds that end up as small part of a bigger project - let’s say as a widget (node module) in a portal (react)?

The exported zip contains several config/settings files which are referencing files/assets of the build. These paths become invalid after compiling the project because the export folder structure cannot be applied to the whole big project.

Sure, I can modify the file paths in the settings/config files but then I have to re-do them everytime a new build is required.

Also, there are crazy parts in the exported code like window.pc = pc; because __game-scripts.js requires pc to be global. I see that it’s totally fine in a standalone build but as part of a bigger project that contains many pc “apps” (widgets) and lots of other stuff, this is problematic. Any plans to clean that up?

Maybe I’m missing something … not sure.

EDIT: yes, I’ve missed assetPrefix and scriptPrefix in __settings__.js.

Any replies appreciated,

I’ve also done this. You can view the source here:

What I did was set up the 3D graphical stuff in playcanvas, including having a scripts folder. You can view the PC project base here:

Essentially, I download the whole project as a zip and drop it in the ‘canvas/’ folder. I have a Gruntfile.js in the root directory of the ‘cybers-cafe’ node project to copy or minify the scripts I develop on, so that I don’t need to use PC UI and change the project, redownload the zip. But that’s up to you. Either way, anything playcanvas related (including JS files) is put into the playcanvas project ‘canvas/’ folder. This is served by node as static files folder (see app.js)

as for editing the files in ‘canvas/’ directly, i added const.js, which is a customized settings.js. I remove the ‘window.’ prefix in there. the only pain is updating the scripts array when you change scripts in the PC project and replace the ‘canvas/’ folder contents with that zip. I don’t run into many issues with that file. I don’t use settings.js because i dont use index.html.

Also note i renamed config.json cfg.json, just because I might forget the edits and it would be a red flag that I didn’t make the proper changes to the ‘canvas/’ folder after re-importing the PC project. It doesn’t happen alot because I prefer developing in the node environment with whatever code editor I want etc.

Best of luck!

I should also mention about start and loading js files. I put them under ‘views/home.jade’. IDK if you heard of JADE but it is now called PUG and is a templating language for HTML.

      div(id="viewport-div" android:focusable="true" android:focusableInTouchMode="true" maximum-scale=1)

essentially just loading the script here instead of using an HTML file. it is RENDERED by NODE in app.js:

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
// Home page with viewport + entities interface
app.get('/', function (req, res) {
  res.render("home.jade", {

Just curious, why do you need more than one instance of pc?