ember-cli-sass icon indicating copy to clipboard operation
ember-cli-sass copied to clipboard

How to specify asset urls after baseUrl deprecation?

Open tschoartschi opened this issue 9 years ago • 1 comments

Hey!

After fixing the baseUrl deprecation I've got the problem that specifying the urls for assets in a scss file becomes quite tricky. In our setup I know the baseUrl (or nowadays the rootURL) at build time and not when I write the scss file. I opened a thread on discuss.emberjs.com for more details click here.

I also built a "hacky" solution which works fine for us but I'm interested what would be a good approach to solve this problem. Are there any plans in solving this issue within ember-cli-sass?

Thanks a lot

tschoartschi avatar Nov 28 '16 16:11 tschoartschi

I have also had similar problems with this, after digging a little bit I found this approach to use the function feature of sassOptions: https://stackoverflow.com/questions/33025880/is-it-possible-to-pass-environment-variables-to-ember-cli-sass-during-build

This let me pass through an environment option that I could use for my asset URLs, you could possible do something similar with rootURL if you needed to:

$rootURL: '';

@if environment() == 'development' {
  $rootURL: '/foobar';
}

.image {
  background: url('#{$rootURL}/images/images.png');
}

nmcclay avatar Jul 07 '17 16:07 nmcclay