There’s missing documentation on how to do this.
I’m not sure if it assumes a base level of knowledge of web development because
I’m trying to use parcel with react. I’ve created an npmdef and configured as much as I thought was necessary - I’ve copied and pasted stuff from the react template made by needle.
I’m not sure what to then do with it? I’ve tried adding the npmdef in the dependencies list in the ExportInfo component, but that will still build the default vite template
Also, when I start a new scene, and add the ExportInfo component, I no longer get an option to choose from a template, so I’m not sure what has changed there.
Hi, can you briefly explain what your goal is? Do you want to create a custom web project template that you can re-use for multiple projects and to quickly spin up a new project using that template? Or is your goal to just use your “parcel with react” web project?
So there are two options for how/where to manage your project templates.
Option A your web project is inside Unity Assets or a local Unity package (this can of course also be on github) - in which case you put the ProjectTemplate scriptable object inside the directory that has your web project (make sure to not install it - you dont want to have a node_modules folder in Unity)
Option B (which i would recommend) - is to create a separate github repository for your web project which just contains the web project (and which you just reference via the Remote Url inside the “Project Template” scriptable object in Unity)
Select your parcel/react project in the ExportInfo component with the “Pick” button and make sure it starts/runs as expected (the directory needs to contain a package.json). The Unity package will generate a needle.config file which you can use to configure where to export your GLB files to and where your scripts, which directory is the output directory etc
Once your project runs as expected I would create a github repository and push the project to that repo. In Unity you can then (if you want to spin up a new web project using your template) just paste the github URL into the ExportInfo “Directory” field (it will recognize the github url and give you an option to clone it) OR you can create a new Project Template scriptable object (the one you sent a screenshot above) and paste the github URL in “Remote Url” field in which case your custom template will show up in the ExportInfo templates dropdown
What you did above is basically telling the package that your whole Assets folder is a web project template. Thats why its not working and surely not your intention. The inspector should be more clear about that!!!
Npmdefs should be used to enhance a web project and add functionality/features, they are installed into a web project (just like a unity package is installed to a unity project)
Ok, thanks for the detailed response. I think I follow, but haven’t yet tried it - I will come back to you shortly!
Although I don’t understand what the Npmdef is for then? I am following the Needle Docs guide and it refers to them. I’ve made one, and have configured the package.json. What do I do with it then?
I hope this helps. You create them to split and manage your project into modular parts that you can add or remove to any web project. What exactly you put inside them is up to you and you dont have to use them at all if you dont want/need to.
For example our samples have multiple npmdefs that contain different scripts (or reference other packages from npm) that we add/remove to the vite template per sample (if the sample needs it)
That way our vite template stays minimal and doesnt have dependencies you might not want or need. And the same code can be added to sveltekit or react…