Fix #76 where all placeholder app modules are treated as externals

This commit is contained in:
Jia Hao 2016-01-25 10:31:54 +08:00
parent a8d020f3e2
commit a6df09fda5
1 changed files with 45 additions and 13 deletions

View File

@ -1,18 +1,50 @@
var fs = require('fs');
var electronPublicApi = [
'electron',
// for modules which use deprecated api
// modules are taken from https://github.com/atom/electron/tree/master/docs/api
'app',
'screen'
// Uncomment as needed if some external module uses the deprecated api
// 'accelerator',
// 'auto-updater',
// 'browser-window',
// 'chrome-command-line-switches',
// 'clipboard',
// 'content-tracing',
// 'crash-reporter',
// 'desktop-capturer',
// 'dialog',
// 'download-item',
// 'environment-variables',
// 'file-object',
// 'frameless-window',
// 'global-shortcut',
// 'ipc-main',
// 'ipc-renderer',
// 'menu-item',
// 'menu',
// 'native-image',
// 'power-monitor',
// 'power-save-blocker',
// 'process',
// 'protocol',
// 'remote',
// 'session',
// 'shell',
// 'synopsis',
// 'tray',
// 'web-contents',
// 'web-frame',
// 'web-view-tag',
// 'window-open'
];
// http://jlongster.com/Backend-Apps-with-Webpack--Part-I
// set all modules in node_modules as external
var nodeModules = {};
fs.readdirSync('./app/node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
// add electron to external module
nodeModules.electron = 'commonjs electron';
electronPublicApi.forEach(apiString => {
nodeModules[apiString] = 'commonjs ' + apiString;
});
module.exports = {
target: 'node',