Importing ES6 classes inside styles folder


#1

I have some ember apps which share some styles. For the moment there are just two files I want to share between those ember apps, one CSS for static colors and one JS with a class with static variables for colors that may change in runtime.

For this purpose I’m using subtrees to share a folder named “common” inside styles folder, where I have two mentioned files.

The problem is that I can’t import any JS file inside styles folder from elsewhere outside styles folder. I imagine this happens because ember-cli build process exclude styles folder.

I’ve been looking for config options to change this behaviour but I didn’t found it.

Does anyone know if there’s a workaround to import ES6 classes from JS files inside styles folder?


#3

First of all thanks for your answer, I’m also kind a newbie and any help is useful.

Yesterday I was looking ember-cli docs and I saw the possibility of importing js files in ember-cli-build config file, as you posted. The problem is that I want to have a js file written in ES6 and if I try to import that way it will not work, it must be transpiled, because those imported files will just be bundled into vendor.js without any tranpile process.

Finally I think I’m going to move this file outside styles folder. It’s not what I wanted but it’s not a big deal.

Anyway, thanks :slight_smile:


#4

I tried it out and I guess you are right in moving it out of the styles dir.


#5

ps: Since it might mislead someone, I’ve deleted my earlier reply which suggested to add a line to ember-cli-build.js in order to import from a js file under the app directory.