2016-05-24 19:12:06 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const path = require('path')
|
2016-06-16 22:10:31 +00:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
2016-10-26 20:37:56 +00:00
|
|
|
const webpack = require('webpack')
|
2017-04-17 20:24:00 +00:00
|
|
|
const merge = require('webpack-merge')
|
2016-05-24 19:12:06 +00:00
|
|
|
|
2017-04-13 13:58:42 +00:00
|
|
|
const devClientId = '3a723b10ac5575cc5bb9'
|
|
|
|
const devClientSecret = '22c34d87789a365981ed921352a7b9a8c3f69d54'
|
|
|
|
|
2017-04-17 20:24:00 +00:00
|
|
|
const commonConfig = {
|
|
|
|
externals: [
|
|
|
|
'electron',
|
|
|
|
'net',
|
|
|
|
'remote',
|
|
|
|
'shell',
|
|
|
|
'app',
|
|
|
|
'ipc',
|
|
|
|
|
|
|
|
'keytar',
|
|
|
|
'7zip',
|
|
|
|
'dugite',
|
|
|
|
],
|
2016-05-24 19:12:06 +00:00
|
|
|
output: {
|
2016-06-24 13:52:24 +00:00
|
|
|
filename: '[name].js',
|
2017-04-17 20:24:00 +00:00
|
|
|
path: path.resolve(__dirname, '..', 'out'),
|
2016-05-24 19:12:06 +00:00
|
|
|
libraryTarget: 'commonjs2'
|
|
|
|
},
|
2017-04-17 20:24:00 +00:00
|
|
|
plugins: [
|
|
|
|
new webpack.NoEmitOnErrorsPlugin()
|
|
|
|
],
|
|
|
|
resolve: {
|
|
|
|
extensions: [ '.js', '.ts', '.tsx' ],
|
|
|
|
modules: [ path.resolve(__dirname, 'node_modules/') ],
|
|
|
|
mainFields: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main']
|
|
|
|
},
|
|
|
|
node: {
|
|
|
|
__dirname: false,
|
|
|
|
__filename: false
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const mainConfig = merge({}, commonConfig, {
|
|
|
|
entry: { main: path.resolve(__dirname, 'src/main-process/main') },
|
|
|
|
target: 'electron-main',
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
include: path.resolve(__dirname, 'src'),
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
const rendererConfig = merge({}, commonConfig, {
|
|
|
|
entry: { renderer: path.resolve(__dirname, 'src/ui/index') },
|
|
|
|
target: 'electron-renderer',
|
2016-05-24 19:12:06 +00:00
|
|
|
module: {
|
2017-04-17 20:24:00 +00:00
|
|
|
rules: [
|
2016-05-24 19:12:06 +00:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
2017-04-17 20:24:00 +00:00
|
|
|
include: path.resolve(__dirname, 'src'),
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/,
|
2016-06-16 17:23:52 +00:00
|
|
|
},
|
2016-06-16 23:37:57 +00:00
|
|
|
{
|
|
|
|
test: /\.(jpe?g|png|gif|ico)$/,
|
2017-04-17 20:24:00 +00:00
|
|
|
use: ['file?name=[path][name].[ext]']
|
2016-05-24 19:12:06 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2016-06-24 13:52:24 +00:00
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
2016-07-21 18:31:30 +00:00
|
|
|
'template': path.join(__dirname, 'static', 'index.html'),
|
2016-06-24 13:52:24 +00:00
|
|
|
'chunks': ['renderer']
|
|
|
|
}),
|
2017-04-17 20:24:00 +00:00
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
const sharedConfig = merge({}, commonConfig, {
|
|
|
|
entry: { shared: path.resolve(__dirname, 'src/shared-process/index') },
|
|
|
|
target: 'electron-renderer',
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
include: path.resolve(__dirname, 'src'),
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
2016-06-24 13:52:24 +00:00
|
|
|
new HtmlWebpackPlugin({
|
2016-06-24 15:48:43 +00:00
|
|
|
'filename': 'shared.html',
|
|
|
|
'chunks': ['shared']
|
2016-10-26 20:37:56 +00:00
|
|
|
}),
|
2016-06-24 13:52:24 +00:00
|
|
|
],
|
2017-04-17 20:24:00 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const askPassConfig = merge({}, commonConfig, {
|
|
|
|
entry: { 'ask-pass': path.resolve(__dirname, 'src/ask-pass/main') },
|
|
|
|
target: 'node',
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
include: path.resolve(__dirname, 'src'),
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
}
|
|
|
|
]
|
2016-09-06 18:24:19 +00:00
|
|
|
},
|
2017-04-17 20:24:00 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
main: mainConfig,
|
|
|
|
shared: sharedConfig,
|
|
|
|
renderer: rendererConfig,
|
|
|
|
askPass: askPassConfig,
|
2016-09-06 18:24:19 +00:00
|
|
|
replacements: {
|
2017-04-13 14:09:57 +00:00
|
|
|
__OAUTH_CLIENT_ID__: JSON.stringify(process.env.DESKTOP_OAUTH_CLIENT_ID || devClientId),
|
|
|
|
__OAUTH_SECRET__: JSON.stringify(process.env.DESKTOP_OAUTH_CLIENT_SECRET || devClientSecret),
|
2016-09-23 19:34:55 +00:00
|
|
|
__DARWIN__: process.platform === 'darwin',
|
|
|
|
__WIN32__: process.platform === 'win32'
|
2016-05-24 19:12:06 +00:00
|
|
|
}
|
|
|
|
}
|