Skip to main content

web_assets 0.0.1 copy "web_assets: ^0.0.1" to clipboard
web_assets: ^0.0.1 copied to clipboard

This library contains the hook protocol specification for bundling uri-resolvable assets with Dart packages.

package:web_assets Coverage Status pub package package publisher

A library to use in build (hook/build.dart) and link (hook/link.dart) hooks for building and bundling assets for Dart web applications.

When a Dart application is built for the web, web assets are included as part of the generated bundle and their URI can be resolved at runtime. Essentially, these assets are files in a web/ directory that can be contributed by packages.

Data assets can be added in a build hook as follows:

import 'package:hooks/hooks.dart';
import 'package:web_assets/web_assets.dart';

void main(List<String> args) async {
  await build(args, (input, output) async {
    if (input.config.buildWebUriAssets) {
      final packageName = input.packageName;
      final assetPathInPackage = input.packageRoot.resolve('...');
      final assetPathDownload = input.outputDirectoryShared.resolve('...');

      output.assets.webUri.add(
        WebUriAsset(
          package: packageName,
          name: '...',
          file: assetPathInPackage,
        ),
      );
    }
  });
}

For more documentation of hooks, refer to the API docs of package:hooks.

Status: Experimental #

NOTE: This package is currently experimental and published under the labs.dart.dev pub publisher in order to solicit feedback.

For packages in the labs.dart.dev publisher we generally plan to either graduate the package into a supported publisher (dart.dev, tools.dart.dev) after a period of feedback and iteration, or discontinue the package. These packages have a much higher expected rate of API and breaking changes.

Your feedback is valuable and will help us evolve this package. For bugs, please file an issue in the bug tracker.

0
likes
160
points
399
downloads

Documentation

API reference

Publisher

verified publisherlabs.dart.dev

Weekly Downloads

This library contains the hook protocol specification for bundling uri-resolvable assets with Dart packages.

Repository (GitHub)
View/report issues
Contributing

Topics

#assets #hooks

License

BSD-3-Clause (license)

Dependencies

hooks

More

Packages that depend on web_assets