gulp-useref icon indicating copy to clipboard operation
gulp-useref copied to clipboard

Add support for absolute paths with the new option "base"

Open manuel-di-iorio opened this issue 10 years ago • 2 comments

First of all, thank you to have inserted the new option ( https://github.com/jonkemp/gulp-useref/issues/141#issuecomment-154697616 ).

The issue is simple, this new option only supports paths relative to the script location. Useref should be able to understand when the base path is absolute or not, using the native path.isAbsolute(). That's it :)

PS: The absolute path support is already implemented for the searchPath option.

manuel-di-iorio avatar Nov 26 '15 21:11 manuel-di-iorio

I'm afraid I don't understand the problem this should solve.

jonkemp avatar Dec 17 '15 16:12 jonkemp

useref({
    base: "../relative" //supports relative paths
    base: "I:\\Users\\Computer\\Desktop" //<-- not supported
}) 

The base option is the location of the assets (js, css) and it's relative to process.cwd() Unfortunally cwd is not always the root folder of the app, ie. running the gulpfile inside another folder, so that I have to write something like: "../../myAppName/public/www". A unexpected behavior if I have to share the config of the gulpfile

You may add the support for absolute paths for that option:

var path = require("path");

if (!path.isAbsolute(options.base)) 
    options.base = path.join(process.cwd(), options.base);

manuel-di-iorio avatar Dec 17 '15 16:12 manuel-di-iorio