Vue-cli: Expose webpack build stats (like hash) for plugins

Created on 11 Sep 2018  路  1Comment  路  Source: vuejs/vue-cli

What problem does this feature solve?

I'm trying to build a plugin that would write webpack build hash in a file that a backend framework (in this case Django) could read for better integration between front and backend. The current UI app reads the generated stats JSON and then deletes it, but I haven't found a way to hook into this data. It would be useful to be able to get either the hash or the full webpack generated stats file in development mode, too.

What does the proposed API look like?

For example, add configuration like: "webpackStats: true" and "webpackStatsFile: 'stats.json'"

feature request cli-service build

Most helpful comment

I think a plugin like this one should solve this nicely for you.

https://www.npmjs.com/package/stats-webpack-plugin

No need for another config option in my opinion.

// vue.config.js
const StatsPlugin = require('stats-webpack-plugin')
module.exports = {
  configureWebpack: {
    plugins: [new StatsPlugin('stats.json')]
  }
}

>All comments

I think a plugin like this one should solve this nicely for you.

https://www.npmjs.com/package/stats-webpack-plugin

No need for another config option in my opinion.

// vue.config.js
const StatsPlugin = require('stats-webpack-plugin')
module.exports = {
  configureWebpack: {
    plugins: [new StatsPlugin('stats.json')]
  }
}
Was this page helpful?
0 / 5 - 0 ratings