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 minfolder option to put any minified files into different folder,… #68

Open
wants to merge 5 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ function processJsBundle(options, jsBundle, bundleDir, jsFiles, bundleName, cb)

var filePath = path.join(bundleDir, file),
jsPath = path.join(bundleDir, jsFile),
minJsPath = getMinFileName(jsPath);
minJsPath = options.minfolder
? path.join(bundleDir, options.minfolder, path.dirname(jsFile), getMinFileName(path.basename(jsFile)))
: getMinFileName(jsPath);

var i = index++;
pending++;
Expand Down Expand Up @@ -357,7 +359,9 @@ function processCssBundle(options, cssBundle, bundleDir, cssFiles, bundleName, c

var filePath = path.join(bundleDir, file),
cssPath = path.join(bundleDir, cssFile),
minCssPath = getMinFileName(cssPath);
minCssPath = options.minfolder
? path.join(bundleDir, options.minfolder, path.dirname(cssFile), getMinFileName(path.basename(cssFile)))
: getMinFileName(cssPath);

var i = index++;
pending++;
Expand Down Expand Up @@ -489,9 +493,11 @@ function compileAsync(options, mode, compileFn /*compileFn(text, textPath, cb(co
if (options.outputbundleonly) {
cb(minText);
} else {
fs.writeFile(compileTextPath, minText, 'utf-8', function(_) {
cb(minText);
});
fs.mkdirp(path.dirname(compileTextPath), null, function(_) {
fs.writeFile(compileTextPath, minText, 'utf-8', function(_) {
cb(minText);
});
});
}
};
compileFn(text, textPath, onAfterCompiled);
Expand Down Expand Up @@ -544,3 +550,13 @@ function readTextFile(filePath, cb) {
cb(stripBOM(fileContents));
});
}

fs.mkdirp = function(dirpath, mode, callback) {
fs.mkdir(dirpath, mode, function(error) {
if (error && error.errno === 34) {
fs.mkdirp(path.dirname(dirpath), mode, callback);
fs.mkdirp(dirpath, mode, callback);
}
callback && callback(error);
});
};