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

Web build folder configurable #356

Open
wants to merge 3 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
2 changes: 1 addition & 1 deletion command/flambe.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ cmd.setDefaults({action: function (args) {
flambe.loadConfig(args.config)
.then(function (config) {
var server = new flambe.Server();
server.start();
server.start(config);
}));
}});

Expand Down
30 changes: 15 additions & 15 deletions command/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,20 @@ exports.build = function (config, platforms, opts) {
var libPaths = getAllPaths(config, "libs");
var srcPaths = getAllPaths(config, "src");
var webPaths = getAllPaths(config, "web");
var webOutput = "build/" + get(config, "output web", "web");

var _preparedWeb = false;
var prepareWeb = function () {
if (!_preparedWeb) {
_preparedWeb = true;

wrench.mkdirSyncRecursive("build/web/targets");
copyFileSync(DATA_DIR+"flambe.js", "build/web/flambe.js");
wrench.mkdirSyncRecursive(webOutput + "/targets");
copyFileSync(DATA_DIR+"flambe.js", webOutput + "/flambe.js");

return copyDirs(webPaths, "build/web", {includeHidden: true})
return copyDirs(webPaths, webOutput, {includeHidden: true})
.then(function () {
if (fs.existsSync("icons")) {
return copyDirs("icons", "build/web/icons");
return copyDirs("icons", webOutput + "/icons");
}
});
}
Expand Down Expand Up @@ -220,27 +221,25 @@ exports.build = function (config, platforms, opts) {
};

var buildHtml = function () {
var outputDir = "build/web";

return prepareWeb(outputDir)
.then(function () { return prepareAssets(outputDir+"/assets") })
return prepareWeb(webOutput)
.then(function () { return prepareAssets(webOutput+"/assets") })
.then(function (assetFlags) {
console.log("Building: " + outputDir);
console.log("Building: " + webOutput);
return buildJS({
target: "html",
outputDir: outputDir,
outputDir: webOutput,
assetFlags: assetFlags,
});
});
};

var buildFlash = function () {
var swf = "build/web/targets/main-flash.swf";
var swf = webOutput + "/targets/main-flash.swf";
var flashFlags = swfFlags(false).concat([
"-swf-version", SWF_VERSION, "-swf", swf]);

return prepareWeb()
.then(function () { return prepareAssets("build/web/assets") })
.then(function () { return prepareAssets(webOutput + "/assets") })
.then(function (assetFlags) {
console.log("Building: " + swf);
return haxe(commonFlags.concat(assetFlags).concat(flashFlags));
Expand Down Expand Up @@ -678,12 +677,13 @@ var Server = function () {
};
exports.Server = Server;

Server.prototype.start = function () {
Server.prototype.start = function (config) {
var self = this;
var connect = require("connect");
var url = require("url");
var websocket = require("websocket");

var webOutput = "build/" + get(config, "output web", "web");
// Fire up a Haxe compiler server, ignoring all output. It's fine if this command fails, the
// build will fallback to not using a compiler server
spawn("haxe", ["--wait", HAXE_COMPILER_PORT], {stdio: "ignore"});
Expand Down Expand Up @@ -718,7 +718,7 @@ Server.prototype.start = function () {
})
.use(connect.logger("tiny"))
.use(connect.compress())
.use(connect.static("build/web"))
.use(connect.static(webOutput))
.listen(HTTP_PORT, host);
console.log("Serving on http://localhost:%s", HTTP_PORT);

Expand Down Expand Up @@ -764,7 +764,7 @@ Server.prototype.start = function () {
watch.createMonitor("assets", {interval: 200}, function (monitor) {
monitor.on("changed", function (file) {
console.log("Asset changed: " + file);
var output = "build/web/"+file;
var output = webOutput + "/"+file;
if (fs.existsSync(output)) {
var contents = fs.readFileSync(file);
fs.writeFileSync(output, contents);
Expand Down