Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide WASM file from our own CDN #423

Open
1 of 2 tasks
mabernethy opened this issue Dec 4, 2024 · 5 comments
Open
1 of 2 tasks

Provide WASM file from our own CDN #423

mabernethy opened this issue Dec 4, 2024 · 5 comments
Assignees
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@mabernethy
Copy link

mabernethy commented Dec 4, 2024

Overview

Would it be possible to provide the dotlottie.wasm file from our own CDN, or even with in the React bundle itself (I'm using DotLottieReact). I noticed in the network tab when I'm loading one of the DotLottie retrieves the WASM file from the jsdeliver CDN. Our clients are security minded and have a white list of approved IP addresses that our software can access from behind their firewalls. It would be easier to avoid asking all of them to update their whitelist.
...

Type

  • [ X] New feature
  • Changes to existing features

Motivation

What inspired this feature request? What problems were you facing, or what else makes you think this should be
included?
My company's usage of DotLottie would be restricted if we aren't able to supply the WASM file from our own CDN or within the bundle itself.
...

Labels

  • Add the Type: Feature Request label to this issue.
@Malith-Rukshan
Copy link

You can achieve this by using the following code:

import { setWasmUrl } from @lottiefiles/dotlottie-react”;

React.useEffect(() => {
  setWasmUrl(/lib/dotlottie-player.wasm”);
}, []);

Note: The useEffect is optional.

@theashraf
Copy link
Member

theashraf commented Dec 9, 2024

@mabernethy If you’re using a js bundler like vite or webpack, you can use a file/url loader to resolve the file path of the WASM file into a self-hosted URL.

Once you have the URL, you can use the setWasmUrl function exported by the @lottiefiles/dotlottie-react package to set the WASM URL.

Example (works well with vite):

import { setWasmUrl } from "@lottiefiles/dotlottie-react";

setWasmUrl(
  new URL(
    "./node_modules/@lottiefiles/dotlottie-web/dist/dotlottie-player.wasm", 
    import.meta.url
  ).href
);

I’ll update the docs as well to make this use case clear. Thanks for bringing this up!

@theashraf theashraf added documentation Improvements or additions to documentation question Further information is requested labels Dec 9, 2024
@theashraf theashraf self-assigned this Dec 9, 2024
@jared-f
Copy link

jared-f commented Dec 12, 2024

hello 👋 @theashraf! I have similar use case but for vue. Looks like setWasmUrl in vue package works similarly to the react package.

Can you please confirm that the example approach above works for a vue app built w vite?

Thank you!

@lienze87
Copy link

@jared-f 在vite中可以这样引入

import { DotLottie } from '@lottiefiles/dotlottie-web'
import dotlottiePlayer from '@lottiefiles/dotlottie-web/dist/dotlottie-player.wasm?url'

DotLottie.setWasmUrl(dotlottiePlayer)

@theashraf
Copy link
Member

hello 👋 @theashraf! I have similar use case but for vue. Looks like setWasmUrl in vue package works similarly to the react package.

Can you please confirm that the example approach above works for a vue app built w vite?

Thank you!

@jared-f yes it should work the same way across different frameworks.

Refer to Vite’s Asset Guide for more details. This approach works for Vite based Vue apps just as it does for React.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants