forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.desktop.js
66 lines (60 loc) · 2.16 KB
/
webpack.desktop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const path = require('path');
const webpack = require('webpack');
const _ = require('underscore');
const desktopDependencies = require('../../desktop/package.json').dependencies;
const getCommonConfig = require('./webpack.common');
/**
* Desktop creates 2 configurations in parallel
* 1. electron-main - the core that serves the app content
* 2. web - the app content that would be rendered in electron
* Everything is placed in desktop/dist and ready for packaging
* @param {Object} env
* @returns {webpack.Configuration[]}
*/
module.exports = (env) => {
const rendererConfig = getCommonConfig({...env, platform: 'desktop'});
const outputPath = path.resolve(__dirname, '../../desktop/dist');
rendererConfig.name = 'renderer';
rendererConfig.output.path = path.join(outputPath, 'www');
// Expose react-native-config to desktop-main
const definePlugin = _.find(rendererConfig.plugins, (plugin) => plugin.constructor === webpack.DefinePlugin);
const mainProcessConfig = {
mode: 'production',
name: 'desktop-main',
target: 'electron-main',
entry: {
main: './desktop/main.js',
contextBridge: './desktop/contextBridge.js',
},
output: {
filename: '[name].js',
path: outputPath,
libraryTarget: 'commonjs2',
},
resolve: rendererConfig.resolve,
plugins: [definePlugin],
externals: [..._.keys(desktopDependencies), 'fsevents'],
node: {
/**
* Disables webpack processing of __dirname and __filename, so it works like in node
* https://github.com/webpack/webpack/issues/2010
*/
__dirname: false,
__filename: false,
},
module: {
rules: [
{
test: /react-native-onyx/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-react'],
},
},
},
],
},
};
return [mainProcessConfig, rendererConfig];
};