[Vuejs]-How to write a JSON file into the dist folder by vue.config.js webpack config?

0👍

I found a solution.

const fs = require('fs-extra');

function JsonWebpackPlugin() {
  fs.writeJSONSync('./public/some.json', { a: 1 });
}
JsonWebpackPlugin.prototype.apply = new Function();

module.exports = {
    chainWebpack(config) {
        config.plugin('Json').use(JsonWebpackPlugin);
    }
}

Leave a comment