embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
339 stars 139 forks source link

Cannot import assets from app/assets folder #2087

Open simonihmig opened 3 months ago

simonihmig commented 3 months ago

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!

void-mAlex commented 1 month ago

@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 commented 1 month ago

Also have an app/assets folder with no issues

void-mAlex commented 1 month ago

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

simonihmig commented 1 month ago

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