systemjs / plugin-css

CSS loader plugin
MIT License
92 stars 60 forks source link

rootURL option creates absolute paths for font urls in css #99

Closed olgamelnichuk closed 7 years ago

olgamelnichuk commented 8 years ago

Setting rootURL option (tried different values the result is always the same) resolves font urls in CSS to absolute paths, i.e. src:url(/Users/olga/projects/my_project/app/jspm_packages/github/twbs/bootstrap@3.3.7/fonts/glyphicons-halflings-regular.eot);

I've tried rootURL values like 'app', '/', '.', './app', '/app'... the result is always the same: absolute path.

my_project structure:

app
|_ jspm_packages
|_ lib
|   |_ main.js
|_ system.config.js
|_ index.html
Gulpfile.js

gulp task:

function() {

var builder = new Builder('app', 'app/system.config.js');
    builder.config({
        separateCSS: true
    });
    builder.bundle('lib/main.js', '.dist/lib/main.js', {
        minify: false,
        mangle: false
    });
}

Without rootURL option the font paths are like this: src:url(../../app/jspm_packages/github/twbs/bootstrap@3.3.7/fonts/glyphicons-halflings-regular.eot); which is wrong as I expect it to be based on baseURL which is 'app' so it should be like this (if rootURL is '/'): src:url(/jspm_packages/github/twbs/bootstrap@3.3.7/fonts/glyphicons-halflings-regular.eot);

Probably I'm not quite understand the idea behind the rootURL option.

guybedford commented 8 years ago

Thanks, yes this is a bug... I'll look into it when I can.

guybedford commented 8 years ago

Actually wait, what value are you setting the rootURL to? It is supposed to be a reference to a file path in the local file system that represents the rootURL in the browser. So eg /Users/x/path/to/project or project/www relative to the cwd.

yiqingj commented 7 years ago

having same issue here. using jspm builder to build. always have url path resolved to absolute path. using version 0.1.27. My workaround is removing the rootURL and using gulp to replace my relative path to www root with empty string.

yiqingj commented 7 years ago

ok in my case it's because the rootPath didn't match the absolute path. after fixing it everything works now.

guybedford commented 7 years ago

Glad to hear you sorted it out and thanks for following up.