89 lines
2.0 KiB
TypeScript
89 lines
2.0 KiB
TypeScript
|
import * as path from 'path';
|
||
|
import CleanWebpackPlugin from 'clean-webpack-plugin';
|
||
|
import * as webpack from 'webpack';
|
||
|
import * as merge from 'webpack-merge';
|
||
|
import { getReleaseChannel } from './dist-info';
|
||
|
import { getReplacements } from './app-info';
|
||
|
|
||
|
const channel = getReleaseChannel();
|
||
|
|
||
|
export const externals = ['7zip'];
|
||
|
if (channel === 'development') {
|
||
|
externals.push('devtron');
|
||
|
}
|
||
|
|
||
|
const outputDir = 'dist';
|
||
|
const tsConfigBase = '../tsconfig.json';
|
||
|
|
||
|
const atlConfig = {
|
||
|
configFileName: tsConfigBase
|
||
|
};
|
||
|
|
||
|
export const replacements = getReplacements();
|
||
|
|
||
|
const commonConfig: webpack.Configuration = {
|
||
|
optimization: {
|
||
|
noEmitOnErrors: true
|
||
|
},
|
||
|
externals: externals,
|
||
|
output: {
|
||
|
filename: '[name].js',
|
||
|
path: path.resolve(__dirname, '..', outputDir),
|
||
|
libraryTarget: 'commonjs2'
|
||
|
},
|
||
|
module: {
|
||
|
rules: [
|
||
|
{
|
||
|
test: /\.tsx?$/,
|
||
|
include: path.resolve(__dirname, '../src'),
|
||
|
use: [
|
||
|
{
|
||
|
loader: 'awesome-typescript-loader?' + JSON.stringify(atlConfig),
|
||
|
options: {
|
||
|
useCache: true
|
||
|
}
|
||
|
}
|
||
|
],
|
||
|
exclude: /node_modules/
|
||
|
},
|
||
|
{
|
||
|
test: /\.json$/,
|
||
|
loader: 'json-loader'
|
||
|
},
|
||
|
{
|
||
|
test: /\.node$/,
|
||
|
loader: 'awesome-node-loader',
|
||
|
options: {
|
||
|
name: '[name].[ext]'
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
plugins: [
|
||
|
new CleanWebpackPlugin({ verbose: false }),
|
||
|
// This saves us a bunch of bytes by pruning locales (which we don't use)
|
||
|
// from moment.
|
||
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
|
||
|
],
|
||
|
resolve: {
|
||
|
extensions: ['.js', '.ts', '.tsx'],
|
||
|
modules: [path.resolve(__dirname, '../node_modules/')]
|
||
|
},
|
||
|
node: {
|
||
|
__dirname: false,
|
||
|
__filename: false
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export const main = merge({}, commonConfig, {
|
||
|
entry: { main: path.resolve(__dirname, '../src/main') },
|
||
|
target: 'electron-main',
|
||
|
plugins: [
|
||
|
new webpack.DefinePlugin(
|
||
|
Object.assign({}, replacements, {
|
||
|
__PROCESS_KIND__: JSON.stringify('main')
|
||
|
})
|
||
|
)
|
||
|
]
|
||
|
});
|