“Building for a bigger world than mobile”
Wouter van den Broek
@wbroek
AppRegistry.runApplication('Sample', {
rootTag: document.getElementById('root'),
})
const path = require('path')
const webpack = require('webpack')
module.exports = {
mode: 'development',
entry: {
app: ['babel-regenerator-runtime', './index.js'],
},
output: {
path: path.resolve(__dirname, 'electron', 'dist'),
filename: 'bundle.js',
},
node: {
__filename: true,
__dirname: true,
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
},
{
test: /\.(png|ttf)$/,
loader: 'file-loader',
options: {
publicPath: 'dist/',
},
},
],
},
resolve: {
alias: {
'react-native': 'react-native-electron',
},
extensions: ['.web.js', '.js', '.json'],
},
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(true),
}),
],
target: 'electron-renderer',
}
const path = require('path')
module.exports = {
clipboard: false,
content: [path.resolve(__dirname, 'electron')],
port: 8082,
dev: { publicPath: '/dist' },
}
const { app, BrowserWindow } = require('electron')
let mainWindow = null
const createWindow = () => {
mainWindow = new BrowserWindow({
minWidth: 300,
minHeight: 400,
maxWidth: 400,
width: 300,
height: 600,
show: false,
})
mainWindow.on('closed', () => {
mainWindow = null
})
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
mainWindow.loadURL(`file://${__dirname}/index.html`)
}
app.on('ready', () => {
createWindow()
})
const sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
'downstream/core/invariant.js',
/website\/node_modules\/.*/,
'Libraries/Relay/relay/tools/relayUnstableBatchedUpdates.js',
];
const platformBlacklists = {
web: [
'.ios.js',
'.android.js',
],
ios: [
'.web.js',
/node_modules\/react-native-macos\/.*/,
],
android: [
'.web.js',
'.ios.js',
/node_modules\/react-native-macos\/.*/,
],
macos: [
'.ios.js',
'.android.js',
/node_modules\/react-native\/.*/,
],
};
function blacklist(platform, additionalBlacklist) {
return new RegExp('(' +
(additionalBlacklist || []).concat(sharedBlacklist)
.concat(platformBlacklists[platform] || [])
.map(escapeRegExp)
.join('|') +
')$'
);
}
module.exports = {
getProvidesModuleNodeModules: () => ['react-native-macos'],
getPlatforms: () => 'macos',
getBlacklistRE(platform) {
if (process && process.argv.filter(a => a.indexOf('react-native-macos') > -1).length > 0) {
return blacklist('macos')
}
return blacklist(platform);
},
};