# Custom template and bundling

**URL:** <https://forum.needle.tools/t/custom-template-and-bundling/1306>\
**Category:** 🌵 Needle Engine\
**Tags:** question\
**Created:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306 "2023-12-31T00:00:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![discord-import](https://forum.needle.tools/user_avatar/forum.needle.tools/discord-import/32/33_2.png) [@discord-import](https://forum.needle.tools/u/discord-import)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/1 "2023-12-31T00:00:00Z")

</div>

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.

This page seems to have the bare minimum: [Frameworks, Bundlers, HTML | Needle Engine Documentation](https://engine.needle.tools/docs/html.html#bundling-and-web-frontends)

" Select Create/Needle Engine/Project Template to add a ProjectTemplate into the folder you want to use as a template

Done! It’s that simple."

I’m really not sure what that means - I’ve tried that but it’s clear there are more steps and configuration required

I have the Pro License - I am not sure if this is the correct avenue for asking questions

Thanks

[Original Post on Discord](https://discord.com/channels/717429793926283276/1190732592245387285)

_by user 285903863339548673_

---

<div class="post-metadata">

**Author:** ![needle-bot](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-bot/32/20_2.png) [@needle-bot](https://forum.needle.tools/u/needle-bot)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/2 "2023-12-31T00:00:00Z")

</div>

Hello there – we have an experimental AI bot 🤖 that might be able to help you with your question. Would you like to try this out?

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/3 "2023-12-31T00:00:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/4 "2023-12-31T00:00:00Z")

</div>

you dont see this when you add ExportInfo to a new GameObject?  
 ![Capto_Capture_2023-12-30_08-09-12_PM.png](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/e/ed944792c40a90157a8ce157c7e3d7612f6a0896.png)

---

<div class="post-metadata">

**Author:** ![discord-import](https://forum.needle.tools/user_avatar/forum.needle.tools/discord-import/32/33_2.png) [@discord-import](https://forum.needle.tools/u/discord-import)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/5 "2023-12-31T00:00:00Z")

</div>

Hi, thanks for getting back.

I’d like to to be able to the former: spin up a new project with that template. (parcel + react)

In general I’m trying to understand and learn how the web project is put together, so wanted to try making my own web project setup

I can now select a template in the ExportInfo component ( It wasn’t working before because I had to create a new Project Folder, duh)

When I try to generate the project, it complains there is no package.config, even though there is one

_by user 285903863339548673_

---

<div class="post-metadata">

**Author:** ![discord-import](https://forum.needle.tools/user_avatar/forum.needle.tools/discord-import/32/33_2.png) [@discord-import](https://forum.needle.tools/u/discord-import)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/6 "2023-12-31T00:00:00Z")

</div>

![Screenshot_2023-12-30_143223.png](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/c/cbd59e5cffc8d26686edecbbe4d81ed6ee49e756.png)

_by user 285903863339548673_

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/7 "2023-12-31T00:00:00Z")

</div>

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)

1. 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

2. 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

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/8 "2023-12-31T00:00:00Z")

</div>

Our sveltekit template for example is always pulled from github when you create a new project with it [GitHub - needle-engine/sveltekit-sample: Sveltekit with Needle Engine Sample + automatic deployment to github pages](https://github.com/needle-engine/sveltekit-sample)

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/9 "2023-12-31T00:00:00Z")

</div>

you can have a look at how we manage our templates here:

 ![Capto_Capture_2023-12-30_08-39-37_PM.png](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/3/33a1beeba125753db2b5bcbdffd6a9677faa4b73.png)

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/10 "2023-12-31T00:00:00Z")

</div>

The only one that ships with the Unity project still is the Vite template - all other templates are pulled from github when selected

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/11 "2023-12-31T00:00:00Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![discord-import](https://forum.needle.tools/user_avatar/forum.needle.tools/discord-import/32/33_2.png) [@discord-import](https://forum.needle.tools/u/discord-import)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/12 "2023-12-31T00:00:00Z")

</div>

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?

EDIT: just saw your last message

_by user 285903863339548673_

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/13 "2023-12-31T00:00:00Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![discord-import](https://forum.needle.tools/user_avatar/forum.needle.tools/discord-import/32/33_2.png) [@discord-import](https://forum.needle.tools/u/discord-import)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/14 "2023-12-31T00:00:00Z")

</div>

Ok, I think I’m getting there. Although now I get this error:

```Property

```

I’m literally pasting over files from the react template, which I have running no problem

_by user 285903863339548673_

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/15 "2023-12-31T00:00:00Z")

</div>

> <https://github.com/needle-engine/nextjs-sample/blob/main/src/declarations.d.ts>

Maybe the react template is missing this part

---

<div class="post-metadata">

**Author:** ![discord-import](https://forum.needle.tools/user_avatar/forum.needle.tools/discord-import/32/33_2.png) [@discord-import](https://forum.needle.tools/u/discord-import)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/16 "2023-12-31T00:00:00Z")

</div>

Cool - that works.

Now when I add the:

```auto

```

I add `src = "./assets/myScene.glb"`

But it doesn’t appear to load. There are not warnings in the console 😦

Clutching at straws here…

_by user 285903863339548673_

---

<div class="post-metadata">

**Author:** ![discord-import](https://forum.needle.tools/user_avatar/forum.needle.tools/discord-import/32/33_2.png) [@discord-import](https://forum.needle.tools/u/discord-import)\
**Post date:** [December 31, 2023, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/17 "2023-12-31T00:00:00Z")

</div>

[https://cdn.discordapp.com/attachments/1190732592245387285/1190793645981454497/my\_own\_template\_test.zip?ex=65da7701&is=65c80201&hm=4f94d0c80d53a5fea38b5e17f05bbfd9e6d52cfd8dca96c6a11e697d49239644&(image larger than 4 MB)](https://cdn.discordapp.com/attachments/1190732592245387285/1190793645981454497/my_own_template_test.zip?ex=65da7701&is=65c80201&hm=4f94d0c80d53a5fea38b5e17f05bbfd9e6d52cfd8dca96c6a11e697d49239644&)

_by user 285903863339548673_

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [January 1, 2024, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/18 "2024-01-01T00:00:00Z")

</div>

Seems like your HTML element has a size of 0

---

<div class="post-metadata">

**Author:** ![discord-import](https://forum.needle.tools/user_avatar/forum.needle.tools/discord-import/32/33_2.png) [@discord-import](https://forum.needle.tools/u/discord-import)\
**Post date:** [January 2, 2024, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/19 "2024-01-02T00:00:00Z")

</div>

![Screenshot_2024-01-01_195453.png](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/b/b0896e487a0ac4d9b9cde41fca34e0093e70795d.png)  
 ![Screenshot_2024-01-01_195758.png](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/a/a5e36fb24cf126ad22c46edf3b0054b6946186ec.png)

_by user 285903863339548673_

---

<div class="post-metadata">

**Author:** ![discord-import](https://forum.needle.tools/user_avatar/forum.needle.tools/discord-import/32/33_2.png) [@discord-import](https://forum.needle.tools/u/discord-import)\
**Post date:** [January 2, 2024, 12:00am UTC](https://forum.needle.tools/t/custom-template-and-bundling/1306/20 "2024-01-02T00:00:00Z")

</div>

I’ve given it some styling to prove it’s there but it’s still not rendering anything

the component will load into the DOM. However when i wrap it as a react component, as per the Needle React Template, it doesn’t appear on the DOM

_by user 285903863339548673_

[Next page](https://forum.needle.tools/t/custom-template-and-bundling/1306.md?page=2)
