Skip to content

Commit

Permalink
Fix RawAsset loading. (#160)
Browse files Browse the repository at this point in the history
* Prepending raw asset generated bundle name with publicURL.

* Working code. Failing tests.

* Fix whoops.

* Back to working.

* Resolve Raw Asset URL instead of path.
  • Loading branch information
rakannimer authored and devongovett committed Dec 11, 2017
1 parent ce1409e commit 51b90d7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/assets/RawAsset.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const Asset = require('../Asset');
const path = require('path');
const url = require('url');

class RawAsset extends Asset {
// Don't load raw assets. They will be copied by the RawPackager directly.
load() {}

generate() {
const pathToAsset = JSON.stringify(
url.resolve(this.options.publicURL, this.generateBundleName())
);
return {
js: `module.exports=${JSON.stringify(this.generateBundleName())};`
js: `module.exports=${pathToAsset};`
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('javascript', function() {

let output = run(b);
assert.equal(typeof output, 'function');
assert(/^[0-9a-f]+\.txt$/.test(output()));
assert(/^\/[0-9a-f]+\.txt$/.test(output()));
assert(fs.existsSync(__dirname + '/dist/' + output()));
});

Expand Down
2 changes: 1 addition & 1 deletion test/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('typescript', function() {

let output = run(b);
assert.equal(typeof output.getRaw, 'function');
assert(/^[0-9a-f]+\.txt$/.test(output.getRaw()));
assert(/^\/[0-9a-f]+\.txt$/.test(output.getRaw()));
assert(fs.existsSync(__dirname + '/dist/' + output.getRaw()));
});

Expand Down

0 comments on commit 51b90d7

Please sign in to comment.