Require("assets") in ui-hello-react and ui-hello-vue

I’m having trouble getting access to the Assets API.

:white_check_mark: Assets work in the simple quick-start setup.

When I clone either ui-hello-react or ui-hello-vue, install & watch those projects run fine, too.

:x: As soon as I require the assets in the main.js, I’m getting an error.

Running Prerelease 17.0

const assets = require("assets")

Module not found: Error: Can’t resolve ‘assets’ in '/Users/…/Library/Application Support/Adobe/Adobe XD CC (Prerelease)/develop/…

What could be causing this issue?

1 Like

Hi @getflourish,

Those samples use Webpack, which requires XD specific modules like assets or scenegraph to be noted in the externals field of the config file. Refer to this line in the quick-start-react guide.

After you write externals in the config, require those modules in the src/main.jsx file and then run yarn watch to compile.

Hope this helps!

2 Likes

Ah, yes! That’s it. I remember seeing that before. :slight_smile: