Addon Issues
timkendall opened this issue · comments
I get an Cannot find module
error when trying to import my styles into my component in my addon. Example:
import Ember from 'ember';
import layout from './template';
import styles from './styles';
export default Ember.Component.extend({
layout,
styles
});
Pod folder structure:
-addon
-components
-toggle-switch
-component.js
-styles.css
-template.hbs
I'm not sure what is going on but it looks like styles.css
is not being registered as a module in the resolver like template.hbs
is.
Do you have ember-css-modules included in your dependencies
for the addon?
If it's in devDependencies
(which is where ember install
will save it by default), then it will only compile the styles in your dummy app, and not the addon itself – it's the same reason you have to move ember-cli-htmlbars to dependencies
when you ship an addon that has templates in it.
That fixed it! Thanks dude appreciate the quick response. I added a PR for adding that instruction to the Usage in Addons
portion of the README as this a non-obvious step for new Ember devs.
Glad it worked! Thanks for updating the README – there are definitely some gotchas when you get into the murkier corners of addon dependencies