Skip to content

Instantly share code, notes, and snippets.

@michaelgilley
Created June 14, 2016 15:22
Show Gist options
  • Save michaelgilley/2d11ae12edfd567dabd93237b596fb76 to your computer and use it in GitHub Desktop.
Save michaelgilley/2d11ae12edfd567dabd93237b596fb76 to your computer and use it in GitHub Desktop.
Snippet for grabbing Webpack stats in JSON format when using the Node API.
import webpack from 'webpack'
import {writeFileSync} from 'fs'
import {resolve} from 'path'
import config from 'webpack.config.js'
import webpackDevServer from 'webpack-dev-server'
config.profile = true
const compiler = webpack(config)
compiler.plugin('done', (stats) => {
writeFileSync(resolve('./stats.json'), JSON.stringify(stats.toJson()), 'utf8')
})
webpackDevServer(compiler, {
hot: true,
inline: true,
stats: {
colors: true
},
publicPath: config.output.publicPath
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment