Closed oswaldofreitas closed 8 years ago
There is a image plugin for systemjs here https://github.com/systemjs/plugin-image You can try it in your app and bundler should work. Your configuration looks OK to me. Before using that though you have to install the plugin like: jspm install image
.
On a side note, It seems a bit odd to try load and use all the images with systemjs (images/*/). IMHO, specific images may make sense to be used like this in some scenario.
This does not work for me. The image paths are added to config.js
, and the bundle file is created, but the contents of the images are not added to the bundle file.
Instead of loading the bundle file, the browser still loads each image separately.
(disclosure: all images are svg files).
Here is the contents of the bundle file:
System.registerDynamic("github:systemjs/plugin-image@0.1.0/image.js", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
exports.build = false;
exports.fetch = function(load) {
return new Promise(function(resolve, reject) {
var img = load.metadata.img = new Image();
img.onerror = reject;
img.onload = function(evt) {
try {
delete img.onload;
} catch (err) {
img.onload = function() {};
}
resolve('');
};
img.src = load.address;
});
};
exports.instantiate = function(load) {
return load.metadata.img;
};
return module.exports;
});
System.registerDynamic("github:systemjs/plugin-image@0.1.0.js", ["github:systemjs/plugin-image@0.1.0/image"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('github:systemjs/plugin-image@0.1.0/image');
return module.exports;
});
plugin-image
does not support bundling, only loading.
Can I create an image bundle like this?