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

Added support for base option, single entry point only #73

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion index.js
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