Skip to content

Addon Issues #8

Closed
Closed

Description

@timkendall

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.

Activity

  1. dfreeman commented on Mar 5, 2016

    @dfreeman
    Member

    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.

  2. timkendall commented on Mar 5, 2016

    @timkendall
    ContributorAuthor

    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.

  3. dfreeman commented on Mar 5, 2016

    @dfreeman
    Member

    Glad it worked! Thanks for updating the README – there are definitely some gotchas when you get into the murkier corners of addon dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions