Skip to content
Open
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
17 changes: 16 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = function (options, wp, done) {
var webpack = wp || require('webpack');
var entry = [];
var entries = Object.create(null);
var _file;

var stream = through(function (file) {
if (file.isNull()) {
Expand All @@ -77,6 +78,9 @@ module.exports = function (options, wp, done) {
entry = entry || [];
entry.push(file.path);
}

_file = file;

}, function () {
var self = this;
options.output = options.output || {};
Expand Down Expand Up @@ -139,8 +143,19 @@ module.exports = function (options, wp, done) {
path = path.split('?')[0];
}
var contents = fs.readFileSync(path);

// only do this if a relative base has been set in gulp.src options
var pathParts, outputPath = compiler.outputPath;
if (_file.base.indexOf('.') === 0) {
pathParts = _file.path.split('\\');
pathParts.pop();
pathParts.push(path.split('\\').pop());
path = pathParts.join('\\');
outputPath = _file.base;
}

self.queue(new File({
base: compiler.outputPath,
base: outputPath,
path: path,
contents: contents
}));
Expand Down