jonkemp / gulp-inline-css

Inline linked css in an html file. Useful for emails.
MIT License
272 stars 29 forks source link

Stylesheet Path Issues #36

Open markadrake opened 8 years ago

markadrake commented 8 years ago

My gulp src begins with:

dist/**/*.html

My stylesheet has the following path:

/css/app.css

I call InlineCSS:

    .pipe($.inlineCss, {
      applyStyleTags: false,
      removeStyleTags: false,
      removeLinkTags: true,
    })

I get errors trying to access the CSS file.

The results are pretty funky.

Path to Stylesheet InlineCSS Tries to find
/css/app.css dist/[folder-path]/css/app.css
/dist/css/app.css dist/dist/css/app.css
../css/app.css /css/app.css

How is InlineCSS determining the path to my CSS file? Sometimes it wants to pull the directory structure in from the asterisks (first example) other times it completely ignores the path (second and third example) and going up one directory takes you completely out of the dist folder all together (third example).

Is there no way to tell InlineCSS that dist is the root of my site?

I see an options.url available - placing anything here has been unsuccessful. It's definitely not liking strings, it seems to try and access my localhost when I provide anything here. And my site is not running, because the build is not complete.

jonkemp commented 8 years ago

Can you post your gulp task? And can you provide the stack traces?

slavafomin commented 8 years ago

Hello!

I'm having exactly the same issue. I want to specify the base path from which all stylesheet files should be resolved. Because I have nested HTML files and I want to specify absolute path to CSS from them.

slavafomin commented 8 years ago

Wow, I've managed to resolve the issue after looking in this module's source code.

I've specified the base path the following way:

    .pipe(gulpInlineCss({
      url: 'file://' + __dirname + '/dist/',
      // ...
    }))

I would recommend to update the documentation for url parameter, because right now it is incomplete. I would have never guessed to use file:// prefix.

Thank you!