embroider-build/embroider

Cannot import assets from app/assets folder

simonihmig opened this issue ยท 4 comments

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 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

Also have an app/assets folder with no issues

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

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