How to use the parcel-bundler.Asset function in parcel-bundler

To help you get started, we’ve selected a few parcel-bundler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DeMoorJasper / parcel-plugin-svelte / packages / parcel-plugin-svelte / lib / utils.js View on Github external
function getAssetClass() {
  try {
    return require('parcel').Asset;
  } catch (e) {
    return require('parcel-bundler').Asset;
  }
}
github dobesv / parcel-plugin-assets-list / UrlsAsset.js View on Github external
const Asset = require('parcel-bundler').Asset;
const isURL = require('./utils/is-url');
const urlJoin = require('./utils/urlJoin');

class UrlsAsset extends Asset {
    constructor(...args) {
        super(...args);
        this.type = 'json';
    }

    async collectDependencies() {
        for (let key of Object.keys(this.ast)) {
            const originalPath = this.ast[key];
            const assetPath = this.addURLDependency(originalPath);
            if (!assetPath) throw new Error(`Cannot resolve dependency '${originalPath}'`);
            if (!isURL(assetPath)) {
                this.ast[key] = urlJoin(this.options.publicURL, assetPath);