Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
task: async (ctx, task) => {
const baselineFilepath = path.relative(process.cwd(), getBaselineStatsFilepath());
// eslint-disable-next-line no-param-reassign
task.title = `${task.title} (${baselineFilepath})`;
ctx.artifacts = ctx.artifacts.concat([{
webpack: {
stats: extractDataFromWebpackStats(ctx.baselineStats),
},
}]);
},
skip: async (ctx) => {
const getOnEmit = (options) => async (compilation, callback) => {
const {
compare,
baseline,
html,
json,
outDir,
stats: statsOptions,
} = options;
const data = extractDataFromWebpackStats(
compilation.getStats().toJson(statsOptions),
);
// Webpack builtAt is not available yet
if (!data.builtAt) {
data.builtAt = Date.now();
}
const outputPath = get(compilation, 'options.output.path');
const logger = compilation.getInfrastructureLogger
? compilation.getInfrastructureLogger('BundleStats')
: console;
const baselineFilepath = getBaselineStatsFilepath(outputPath);
let baselineStats = null;
task: (ctx, task) => {
const stats = get(ctx, 'artifacts.0.webpack.stats');
const extractedWebpackStats = extractDataFromWebpackStats(stats);
const baselineFilepath = path.relative(process.cwd(), getBaselineStatsFilepath());
return writeBaseline(extractedWebpackStats).then(() => {
// eslint-disable-next-line no-param-reassign
task.title = `${task.title} (${baselineFilepath})`;
});
},
skip: () => !baseline && TEXT.CLI_NO_BASELINE,
data.builtAt = Date.now();
}
const outputPath = get(compilation, 'options.output.path');
const logger = compilation.getInfrastructureLogger
? compilation.getInfrastructureLogger('BundleStats')
: console;
const baselineFilepath = getBaselineStatsFilepath(outputPath);
let baselineStats = null;
try {
if (compare) {
baselineStats = await readBaseline();
baselineStats = extractDataFromWebpackStats(baselineStats);
logger.info(`Read baseline from ${baselineFilepath}`);
}
} catch (err) {
logger.warn(TEXT.PLUGIN_BASELINE_MISSING_WARN);
}
const artifacts = createJobs([
{ webpack: { stats: data } },
...compare ? [{ webpack: { stats: baselineStats } }] : [],
]);
let reports = [];
try {
reports = await createReports(artifacts, { html, json });
ctx.artifacts = artifacts.map((stats) => ({
webpack: {
stats: extractDataFromWebpackStats(stats),
},
}));
}),