Commit 1e151058 authored by Kevin Decker's avatar Kevin Decker Committed by Tim Neutkens

Output webpack build stats as webpack-stats.json (#2828)

parent c927c4f1
......@@ -13,8 +13,8 @@ export default async function build (dir, conf = null) {
const compiler = await webpack(dir, { buildId, buildDir, conf })
try {
await runCompiler(compiler)
await writeBuildStats(buildDir)
const stats = await runCompiler(compiler)
await writeBuildStats(buildDir, stats)
await writeBuildId(buildDir, buildId)
} catch (err) {
console.error(`> Failed to build on ${buildDir}`)
......@@ -46,7 +46,7 @@ function runCompiler (compiler) {
})
}
async function writeBuildStats (dir) {
async function writeBuildStats (dir, stats) {
// Here we can't use hashes in webpack chunks.
// That's because the "app.js" is not tied to a chunk.
// It's created by merging a few assets. (commons.js and main.js)
......@@ -58,6 +58,9 @@ async function writeBuildStats (dir) {
}
const buildStatsPath = join(dir, '.next', 'build-stats.json')
await fs.writeFile(buildStatsPath, JSON.stringify(assetHashMap), 'utf8')
const statsPath = join(dir, '.next', 'webpack-stats.json')
await fs.writeFile(statsPath, JSON.stringify(stats), 'utf8')
}
async function writeBuildId (dir, buildId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment