Optimizer

A plugin type: Apply modifications to the finished bundle

Optimizers are similar to transformers, but they accept a bundle instead of a single asset. At this stage, any ASTs have already been serialized.

import { Optimizer } from "@parcel/plugin";

export default new Optimizer({
async optimize({ bundle, contents, map }) {
let result = minifyCode(contents, map);
return { contents: result.contents, map: result.contents };
},
});

ΒΆ Relevant API

Optimizer parcel/packages/core/types/index.js:1103

type OptimizerΒ = {|
  optimize({|
    bundle: NamedBundle,
    bundleGraph: BundleGraph<NamedBundle>,
    contents: Blob,
    map: ?SourceMap,
    options: PluginOptions,
    logger: PluginLogger,
    getSourceMapReference: (map: ?SourceMap) => Async<?string>,
  |}): Async<BundleResult>,
|}