Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for parent directories in the relativeTo parameter #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function (content) {

var options = loaderUtils.getOptions(this) || {};
var ngModule = getAndInterpolateOption.call(this, 'module', 'ng'); // ng is the global angular module that does not need to explicitly required
var relativeTo = getAndInterpolateOption.call(this, 'relativeTo', '');
var relativeTo = path.normalize(getAndInterpolateOption.call(this, 'relativeTo', ''));
var prefix = getAndInterpolateOption.call(this, 'prefix', '');
var requireAngular = !!options.requireAngular || false;
var absolute = false;
Expand Down Expand Up @@ -35,7 +35,7 @@ module.exports = function (content) {

var relativeToIndex = resource.indexOf(relativeTo);
if (relativeToIndex === -1 || (absolute && relativeToIndex !== 0)) {
throw new Error('The path for file doesn\'t contain relativeTo param');
throw new Error('The path for file "' + resource + '" doesn\'t contain relativeTo param "' + relativeTo + '".');
}

// a custom join of prefix using the custom path sep
Expand Down
1 change: 1 addition & 0 deletions test/src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ console.log(require('../../index.js?relativeTo=/test/src/!html-loader!./test.htm
console.log(require('../../index.js?relativeTo=src/!html-loader!./test.html'));
console.log(require('../../index.js?relativeTo=' + __dirname + '/!html-loader!./test.html'));
console.log(require('../../index.js?relativeTo=/' + __dirname + '/!html-loader!./test.html'));
console.log(require('../../index.js?relativeTo=' + __dirname + '/../!html-loader!./test.html'));
console.log(require('../../index.js?prefix=/prefix!html-loader!./test.html'));
console.log(require('../../index.js?prefix=/prefix/&relativeTo=/' + __dirname + '/!html-loader!./test.html'));
console.log(require('../../index.js?module=[name]&prefix=[folder]&relativeTo=[path]!html-loader!./test.html'));
Expand Down