Skip to content

Commit

Permalink
Merge pull request #922 from stealjs/bundle-assets
Browse files Browse the repository at this point in the history
Test steal-bundler does not move assets below dest
  • Loading branch information
m-mujica authored Jan 12, 2018
2 parents a07fc73 + 08cfc12 commit faba2a4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"pdenodeify": "^0.1.0",
"prettier": "1.9.2",
"pump": "^1.0.2",
"steal-bundler": "^0.3.5",
"steal": "^1.6.4",
"steal-bundler": "^0.3.6",
"steal-parse-amd": "^1.0.0",
"through2": "^2.0.0",
"tmp": "0.0.33",
Expand Down Expand Up @@ -56,7 +57,6 @@
"mockery": "^2.0.0",
"rimraf": "^2.6.2",
"serve-static": "^1.12.6",
"steal": "^1.6.4",
"steal-conditional": "^0.4.0",
"steal-css": "^1.3.1",
"steal-less": "^1.2.2",
Expand Down
10 changes: 10 additions & 0 deletions test/bundle_assets/prod-custom-dest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="./foo/bar/steal.production.js"></script>
</body>
</html>
55 changes: 50 additions & 5 deletions test/bundle_assets_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var asap = require("pdenodeify"),
assert = require("assert"),
comparify = require("comparify"),
fs = require("fs-extra"),
multiBuild = require("../index").build,
optimize = require("../index").optimize,
Expand Down Expand Up @@ -36,7 +35,7 @@ describe("bundleAssets", function(){
}
}).then(function(){
open("test/bundle_assets/prod.html", function(browser, close){
find(browser, "MODULE", function(module){
find(browser, "MODULE", function(){
const logo = path.join(__dirname, "bundle_assets", "dist", "images", "logo.png");
assert(fs.pathExistsSync(logo), "image was copied");

Expand All @@ -50,6 +49,52 @@ describe("bundleAssets", function(){
});
});

it("assets should be put in [BuildOptions.dest] folder", function() {
var dest = "foo/bar";
var root = path.join(__dirname, "bundle_assets");

var config = {
main: "main",
config: path.join(root, "stealconfig.js")
};

var options = {
quiet: true,
minify: false,
dest: dest,
bundleAssets: {
infer: true,
glob: [path.join(root, "assets", "*")]
}
};

return multiBuild(config, options)
.then(function() {
var logo = path.join(root, dest, "images", "logo.png");
assert(fs.pathExistsSync(logo), "should bundle image");

var json = path.join(root, dest, "assets", "some.json");
assert(fs.pathExistsSync(json), "should bundle json file");
})
.then(function() {
return asap(fs.readFile)(
path.join(root, dest, "bundles", "main.css")
)
.then(function(buff) {
return buff.toString();
});
})
.then(function(cssBundle) {
//url(../images/logo.png)
assert(
/url\(\.\.\/images\/logo\.png\)/.test(cssBundle),
"rewrites paths properly"

);
return asap(rmdir)(path.join(root, "foo"));
});
});

it("works with steal-tools optimize", function (done) {
optimize({
main: "main",
Expand All @@ -65,7 +110,7 @@ describe("bundleAssets", function(){
}
}).then(function() {
open("test/bundle_assets/prod-slim.html", function(browser, close){
find(browser, "MODULE", function(module){
find(browser, "MODULE", function(){
const logo = path.join(__dirname, "bundle_assets", "dist", "images", "logo.png");
assert(fs.pathExistsSync(logo), "image was copied");

Expand All @@ -77,5 +122,5 @@ describe("bundleAssets", function(){
}, close);
}, done);
});
})
});
});
});

0 comments on commit faba2a4

Please sign in to comment.