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

Cannot import assets from app/assets folder #2087

Open
simonihmig opened this issue Aug 30, 2024 · 4 comments
Open

Cannot import assets from app/assets folder #2087

simonihmig opened this issue Aug 30, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@simonihmig
Copy link
Collaborator

With webpack's asset loader setup up, you should be able to import assets like images from you app folder. That works indeed, unless you name that folder you put those assets into as... assets! 😅

Doing so, we are getting errors like

Module not found: Error: Can't resolve './assets/image.png' in '/path/to/app/node_modules/.embroider/rewritten-app'

Looking at node_modules/.embroider/rewritten-app, there is an assets folder, but that one contains build output like vendor.js. Seems there is some kind of name clashing happening here. And indeed, renaming that app/assets folder to e.g. app/images does fix that problem!

This is unfortunate, as it is unexpected, and assets is a pretty common choice for... assets! 😏 So likely to trip up other folks!

Note that this is not an issue for classic builds w/ ember-auto-import and allowAppImports!

This is using stable v3 btw!

@simonihmig simonihmig added the bug Something isn't working label Aug 30, 2024
@void-mAlex
Copy link
Collaborator

@simonihmig what is your actual setup?
I ask because I have am app/assets/styles.css
which gets imported in app.js as import './assets/styles.css just fine no error

@kdagnan
Copy link

kdagnan commented Oct 10, 2024

Also have an app/assets folder with no issues

@void-mAlex
Copy link
Collaborator

might I suggest you check any broccoli pipeline that could troll you with an exclude or something?

@simonihmig
Copy link
Collaborator Author

No, nothing special really. As you can see importing an image, using webpack assets loader. I should probably provide a reproduction though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants