var fse = require('fs-extra');
const util = require('util');

const webpack = require('webpack');

const { getReplacements } = require('./app-info');

const replacements = getReplacements();

module.exports = function (config) {
  config.target = 'electron-renderer';

  config.plugins.push(
    new webpack.DefinePlugin(
      Object.assign({}, replacements, {
        __PROCESS_KIND__: JSON.stringify('renderer'),
      })
    )
  );


  // console.log(config.module);
  // console.log(util.inspect(config.module, {showHidden: false, depth: null}));

  var json = util.inspect(config, { showHidden: false, depth: null });
  fse.writeFileSync('webpack.js', json, 'utf8');

  return config;
};
