DEV Community

Cover image for Dataverse Web Resources - Say Goodbye to CRA, Hello to Vite! ๐Ÿš€
Riccardo Gregori
Riccardo Gregori

Posted on

Dataverse Web Resources - Say Goodbye to CRA, Hello to Vite! ๐Ÿš€

If you've been building WebResources for Dataverse using React, TypeScript, and Fluent UI, you've probably already stumbled upon my previous posts on this topic, and probably right now you rely on @_neronotte/cra-template-dataverse-webresources and @_neronotte/cra-template-dataverse-webresources-forms, my scaffolding templates for Create React App (CRA).

Well, times are changing: CRA has officially been deprecated! ๐Ÿ˜ฑ
If you try to start creating a new react app with CRA, since Feb 14th the installer shows you the following deprecation warning:

Deprecation warning from CRA installer

But don't worryโ€”Iโ€™ve got you covered. After some serious hands-on work, Iโ€™ve migrated my templates to Vite, the community-suggested replacement for CRA. Say hello to vite-template-dataverse-webresources! ๐ŸŽ‰

๐Ÿ‘‰ GitHub Repo: https://github.com/neronotte/vite-template-dataverse-webresources

Why Vite? โšก

Vite is faster, leaner, and just better than CRA in so many ways:

  • Instant server startup โฉ
  • Faster hot module replacement ๐Ÿ”ฅ
  • Optimized build process ๐Ÿ—๏ธ
  • Native ESM support ๐Ÿ“ฆ

If you're still on CRA, nowโ€™s the perfect time to migrate!

Whatโ€™s in the Box? ๐Ÿ“ฆ

The repository now contains two branches:

  • ๐ŸŒ Main Branch (for Sitemap & Modal WebResources)
    • Use this template to create WebResources that are accessed from the Dataverse sitemap, or open as modal dialog or side panes in model-driven apps.
  • ๐Ÿ“ Forms Branch (for WebResources inside Forms)
    • Use this template to create WebResources that integrate directly into Dataverse forms, and need to interact with form data and context

How to Get Started ๐Ÿš€

Getting up and running is easier than ever. You can use degit to clone the repo templates. If you don't have it already installed, you can do it via:

npm install -g degit
Enter fullscreen mode Exit fullscreen mode

then just type:

npx degit neronotte/vite-template-dataverse-webresources#main my-webresource
cd my-webresource
npm install
Enter fullscreen mode Exit fullscreen mode

(replace #main with #forms if you want to use the template for form-based WebResources)

And follow the instructions on the README.md file to have everything properly set-up and ready to use. ๐Ÿ’ฅ

To run your WebResource and debug it locally you can simply type:

npm run dev
Enter fullscreen mode Exit fullscreen mode

It will launch Vite local server, tipically on port 5173. You can just open a browser on http://localhost:5173 and you're ready to go!

To build your WebResource in production mode, ready to be deployed in your Dataverse, just type:

npm run build
Enter fullscreen mode Exit fullscreen mode

Then you can use PACX as described here to upload the generated HTML/JS/CSS files into Dataverse.

Migration Made Easy ๐ŸŽฏ

If you've been using CRA for your Dataverse WebResources, moving to Vite is effortless with this template. The structure remains familiar, and the setup process is straightforwardโ€”so you can transition smoothly without hassle.

Check out the repo, give it a try, and let me know if you have any feedback! Contributions are always welcome. ๐Ÿš€๐Ÿ’ก

Happy coding! ๐Ÿ˜ƒ

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay