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

vite.assetsInclude is not working on astro build #4346

Closed
1 task
kagankan opened this issue Aug 16, 2022 · 3 comments · Fixed by #4344 · May be fixed by Kingcrypto38/astro#3
Closed
1 task

vite.assetsInclude is not working on astro build #4346

kagankan opened this issue Aug 16, 2022 · 3 comments · Fixed by #4344 · May be fixed by Kingcrypto38/astro#3
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@kagankan
Copy link
Contributor

What version of astro are you using?

1.0.5

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Windows 10

Describe the Bug

Background

I want to use .glb (3D model data) in Three.js

Bug

  1. add vite.assetsInclude config to astro.config to use .glb as assets file.
vite: {
    assetsInclude: ['**/*.glb'],
}
  1. import .glb file from TS (import cameraMove from '@/assets/models/camera_move.glb';)
  2. it works on astro dev
  3. it doesn't work on astro build. I got errors (.glb is binary file, so there are garbled characters)
vite v3.0.5 building for production...
✓ 3 modules transformed.
[vite:build-import-analysis] Parse error @:5:37
file: C:/Users/Owner/Documents/astro-sample/src/assets/models/camera_move.glb:5:36
3: ?UU? ?��*?UU5?@?��J?UUU?`?��j?UUu?�?UU�?���?�?UU�?���?�?UU�?���?�?UU�?���?�?UU�?
// ...
transforming (5) node_modules\three\build\three.module.js error   Parse error @:5:37
  File:
    C:/Users/Owner/Documents/astro-sample/src/assets/models/camera_move.glb
  Code:
    3: ?UU? ?��*?UU5?@?��J?UUU?`?��j?UUu?�?UU�?���?�?UU�?���?�?UU�?���?�?UU�?���?�?UU�?
// ...
  Stacktrace:
    at parse$b (file:///C:/Users/Owner/Documents/astro-sample/node_modules/vite/dist/node/chunks/dep-5cb728cb.js:33579:355)
    at Object.transform (file:///C:/Users/Owner/Documents/astro-sample/node_modules/vite/dist/node/chunks/dep-5cb728cb.js:40749:27)

Link to Minimal Reproducible Example

https://github.com/kagankan/astro-sample/tree/f62581354ae153089c810ce35c90841da7283078

Participation

  • I am willing to submit a pull request for this issue.
@natemoo-re
Copy link
Member

Thanks for opening an issue @kagankan! I suspect we're not passing this option through to the build as we should be.

Any interest in submitting a PR? This option needs to be passed through in two places:

const viteBuildConfig: ViteConfigWithSSR = {
and
const viteBuildConfig = {

@natemoo-re natemoo-re added - P3: minor bug An edge case that only affects very specific usage (priority) s0-extra-small labels Aug 16, 2022
@bluwy
Copy link
Member

bluwy commented Aug 16, 2022

I actually submitted some refactors to the code today at #4344 which should fix this too.

@kagankan
Copy link
Contributor Author

@bluwy
That's great! 🙌 Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
3 participants