sonda
Version:
Universal bundle analyzer and visualizer that works with most popular bundlers and frameworks.
23 lines (21 loc) • 780 B
JavaScript
import { Config, SondaWebpackPlugin } from "sonda";
//#region src/entrypoints/next.ts
function SondaNextPlugin(userOptions = {}) {
return function Sonda(nextConfig = {}) {
const options = new Config(userOptions, {
integration: "next",
filename: "sonda_[env]_[index]"
});
if (!options.enabled) return nextConfig;
return Object.assign({}, nextConfig, { webpack(config, { nextRuntime, isServer }) {
const env = nextRuntime || "client";
if (env === "edge" || isServer && !options.server) return config;
const sondaOptions = options.clone();
sondaOptions.filename = sondaOptions.filename.replace("[env]", env);
config.plugins.push(new SondaWebpackPlugin(sondaOptions));
return config;
} });
};
}
//#endregion
export { SondaNextPlugin as default };