jonkemp / gulp-inline-css

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

Windows 7 - css (link rel) resolving to path outside of project #26

Closed wdmtech closed 9 years ago

wdmtech commented 9 years ago

gulp-inline-css is working great on Windows 7 (it's saving me bags of time, thank you!). Only thing is:

<link rel="stylesheet" href="css/ink.css" />

is looked for in:

c:\css\ink.css

as per this output:

[11:16:47] Starting 'inlineCss'...

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: ENOENT, open 'c:\css\ink.css'

Process finished with exit code 8

Providing c:\css\ink.css satisfies the task.

My gulpfile:

/*******************************************************************************
DEPENDENCIES
*******************************************************************************/

var gulp = require('gulp'),
    uncss = require('gulp-uncss');
    inlineCss = require('gulp-inline-css'),
    imagemin = require('gulp-imagemin'),
    notify = require('gulp-notify');

/*******************************************************************************
FILE DESTINATIONS (RELATIVE TO ASSETS FOLDER)
*******************************************************************************/

var target = {
    html_src : './*.html',                              // all html files
    html_dest : './build',                              // where to put minified html
    img_src : './images/**/*',                          // all img files
    img_dest : './build/images',                        // where to put minified img
    css_src : './css/*.css',                            // all css files
    css_dest : './build/css/'                           // where to put uncss files
};

/*******************************************************************************
UNCSS TASK
*******************************************************************************/

gulp.task('unCss', function() {
    return gulp.src(target.css_src)
        .pipe(uncss({
            html: ['index.html']
        }))
        .pipe(gulp.dest(target.css_dest))
        .pipe(notify("UNCSS task completed"));
});

/*******************************************************************************
INLINE CSS TASK
*******************************************************************************/

gulp.task('inlineCss', function() {
    return gulp.src(target.html_src)
        .pipe(inlineCss({
                applyStyleTags: true,
                applyLinkTags: true,
                removeStyleTags: false,
                removeLinkTags: true
        }))
        .pipe(gulp.dest(target.html_dest))
        .pipe(notify("Inline-CSS task completed"));
});

/*******************************************************************************
IMAGES MIN TASK
*******************************************************************************/

gulp.task('imageMin', function() {
    return gulp.src(target.img_src)
            .pipe(imagemin())
            .pipe(gulp.dest(target.img_dest))
            .pipe(notify("Images minify task completed"));
});

/*******************************************************************************
DEFAULT TASK
*******************************************************************************/

gulp.task('default', ['unCss', 'inlineCss', 'imageMin'], function() {

});

/*******************************************************************************
WATCH TASK
*******************************************************************************/

gulp.task('watch', function() {
    gulp.watch('./*.html', ['inlineCss']);
});
wdmtech commented 9 years ago

Turns out I was running an old version of Node... No problems now on v0.12.7!