hensei-web/node_modules/parcel-bundler/lib/assets/RawAsset.js
2020-09-11 06:44:42 -07:00

41 lines
No EOL
1.1 KiB
JavaScript

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
const Asset = require('../Asset');
const urlJoin = require('../utils/urlJoin');
const md5 = require('../utils/md5');
class RawAsset extends Asset {
// Don't load raw assets. They will be copied by the RawPackager directly.
load() {}
generate() {
// Don't return a URL to the JS bundle if there is a bundle loader defined for this asset type.
// This will cause the actual asset to be automatically preloaded prior to the JS bundle running.
if (this.options.bundleLoaders[this.type]) {
return {};
}
const pathToAsset = urlJoin(this.options.publicURL, this.generateBundleName());
return [{
type: 'js',
value: `module.exports=${JSON.stringify(pathToAsset)};`
}];
}
generateHash() {
var _this = this;
return (0, _asyncToGenerator2.default)(function* () {
return md5.file(_this.name);
})();
}
}
module.exports = RawAsset;