const path = require('path');
const nodeExternals = require('webpack-node-externals');
const webpack = require('webpack');
const pjson = require('./package.json');
const config = {
    entry: path.resolve(__dirname, "./src/main.js"),
	target: 'electron-main',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'main.js'
    },
	
	externals: [nodeExternals()], // node_modulesをバンドルから除外
	node: {
	  __dirname: false,
	  __filename: false
	},
	
	plugins: [
		new webpack.BannerPlugin({
			banner: `${pjson.name} v${pjson.version} | ${pjson.author} | license: ${pjson.license}`
		})
	]
};
module.exports = (env, argv) => {
    if (argv.mode === 'development') {
        config.mode = 'development';
        config.devtool = 'source-map';
    }
    if (argv.mode === 'production') {
        config.mode = 'production';
    }
    return config;
};