dimanche 15 mars 2020

Import scss from node_modules within ember addon

I'm developing an ember addon which imports sass from it's dependencies. To use it I have the following in my addon -

# my-addon/package.json
...
"dependencies": {
  "lib1": "^1.5.3",
  "lib2": "1.2.3",
  "ember-cli-sass": "^10.0.1",
  "sass": "^1.23.3"
}
...
# my-addon/addon/styles/addon.scss

@import "lib1/assets/stylesheets/styles";
@import "lib2/assets/stylesheets/styles";
# my-addon/ember-cli-build.js

let app = new EmberAddon(defaults, {
  // Add options here
  sassOptions: {
    includePaths: [
      'node_modules'
    ]
  }
});

This way, the dummy app at tests/dummy can resolve the imports. But when I use the addon in my host app, I get

Error: Can't find stylesheet to import.
  ╷
1 │ @import "lib1/assets/stylesheets/styles";
  │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I can modify my host app's ember-cli-build.js to

let app = new EmberAddon(defaults, {
  // Add options here
  sassOptions: {
    includePaths: [
      'node_modules/my-addon/node_modules'
    ]
  }
});

and ideally it should work but sass runs out of memory because it tries to import everything in node_modules of my host app. How do I make this work for both the dummy app and the host app still be able to import namespaced lib scss?




Aucun commentaire:

Enregistrer un commentaire