Skip to content

Instantly share code, notes, and snippets.

@Nantris
Last active November 24, 2018 01:46
Show Gist options
  • Save Nantris/9677167da2f1e0bfe597ce619afcf994 to your computer and use it in GitHub Desktop.
Save Nantris/9677167da2f1e0bfe597ce619afcf994 to your computer and use it in GitHub Desktop.
/**
* Webpack config for production electron main process
*/
import path from 'path';
import webpack from 'webpack';
import merge from 'webpack-merge';
import UglifyJSPlugin from 'uglifyjs-webpack-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import baseConfig from './webpack.config.base';
import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
CheckNodeEnv('production');
const rootPath = process.cwd();
const appFolder = path.join(rootPath, 'app');
const entry = path.join(appFolder, 'main.dev.js');
console.log(`DEBUG_PROD MAIN: ${process.env.DEBUG_PROD}`);
const devtool = 'source-map';
export default merge.smart(baseConfig, {
mode: 'production',
devtool,
entry,
target: 'electron-main',
output: {
path: appFolder,
filename: 'main.prod.js',
},
plugins: [
new webpack.EnvironmentPlugin({
DEBUG_PROD: `${process.env.DEBUG_PROD}`,
}),
],
/**
* Disables webpack processing of __dirname and __filename.
* If you run the bundle in node.js it falls back to these values of node.js.
* https://github.com/webpack/webpack/issues/2010
*/
node: {
__dirname: false,
__filename: false,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment