Last active
November 15, 2017 09:59
-
-
Save yoannmoinet/a300a37aa61f4609c8a95626300b888e to your computer and use it in GitHub Desktop.
Webpack's configuration snippet for Electron.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require('webpack'); | |
const { RENDERER_INPUT, MAIN_INPUT, BUILD_OUTPUT } = require('./bin/config'); | |
// Define a base configuration. | |
const baseConfig = (env) => ({ | |
plugins: [new webpack.DefinePlugin({ | |
IS_PRO: env.IS_PRO ? true : false, | |
IS_PROD: env.IS_PROD ? true : false, | |
IS_PACKAGED: env.IS_PACKAGED ? true : false | |
})], | |
node: { __dirname: false } | |
}); | |
// Extend the base to output both Main's and Renderer's configs. | |
const rendererConfig = (env) => Object.assign( | |
baseConfig(env), | |
{ | |
entry: { renderer: RENDERER_INPUT }, | |
output: { path: BUILD_OUTPUT }, | |
target: 'electron-renderer' | |
} | |
); | |
const mainConfig = (env) => Object.assign( | |
baseConfig(env), | |
{ | |
entry: { main: MAIN_INPUT }, | |
output: { path: BUILD_OUTPUT }, | |
target: 'electron-main' | |
} | |
); | |
module.exports = (env = {}) => [rendererConfig(env), mainConfig(env)]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment