Skip to content

Commit

Permalink
Merge pull request #999 from stealjs/node-prod
Browse files Browse the repository at this point in the history
When running in Node, make sure to add Production bundles
  • Loading branch information
matthewp authored Jan 11, 2017
2 parents bc9f817 + bca494a commit 4eb5d3b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
5 changes: 3 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1159,11 +1159,12 @@ addStealExtension(function (loader) {
parts.pop();
if(last(parts) === "node_modules") {
this.configMain = "package.json!npm";
addProductionBundles.call(this);
parts.pop();
}
}

if(this.isEnv("production") || this.loadBundles) {
addProductionBundles.call(this);
}
} else {
// make sure we don't set baseURL if it already set
if(!cfg.baseURL && !cfg.config && !cfg.configPath) {
Expand Down
5 changes: 3 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,12 @@
parts.pop();
if(last(parts) === "node_modules") {
this.configMain = "package.json!npm";
addProductionBundles.call(this);
parts.pop();
}
}

if(this.isEnv("production") || this.loadBundles) {
addProductionBundles.call(this);
}
} else {
// make sure we don't set baseURL if it already set
if(!cfg.baseURL && !cfg.config && !cfg.configPath) {
Expand Down
5 changes: 3 additions & 2 deletions steal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6232,11 +6232,12 @@ addStealExtension(function (loader) {
parts.pop();
if(last(parts) === "node_modules") {
this.configMain = "package.json!npm";
addProductionBundles.call(this);
parts.pop();
}
}

if(this.isEnv("production") || this.loadBundles) {
addProductionBundles.call(this);
}
} else {
// make sure we don't set baseURL if it already set
if(!cfg.baseURL && !cfg.config && !cfg.configPath) {
Expand Down
2 changes: 1 addition & 1 deletion steal.production.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions test/node-prod/dist/bundles/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
define("stealconfig.js", [], function(){

});
define("app/app", [], function(){
return {
hello: "world"
};
});
12 changes: 12 additions & 0 deletions test/node_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ describe("default configuration", function () {
done();
},done);
});

it("works in production", function(done){
var steal = makeSteal({
env: "server-production",
config: __dirname + "/node-prod/stealconfig.js",
main: "app/app"
});

steal.startup().then(function(main){
assert.equal(main.hello, "world");
}).then(done, done);
});
});

describe("plugins", function(){
Expand Down

0 comments on commit 4eb5d3b

Please sign in to comment.