2018-01-23 19:59:01 +01:00
|
|
|
const path = require('path');
|
2021-04-23 10:45:30 +02:00
|
|
|
const { merge } = require('webpack-merge');
|
2018-01-23 19:59:01 +01:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2021-04-23 10:45:30 +02:00
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2018-01-23 19:59:01 +01:00
|
|
|
const nodeExternals = require('webpack-node-externals');
|
|
|
|
|
|
|
|
const common = {
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
enforce: 'pre',
|
2018-09-12 19:12:44 +02:00
|
|
|
loader: 'tslint-loader',
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: 'ts-loader',
|
2018-09-12 19:12:44 +02:00
|
|
|
exclude: /node_modules\/(?!(@bitwarden)\/).*/,
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
2018-09-12 19:12:44 +02:00
|
|
|
],
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
|
|
|
plugins: [],
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.tsx', '.ts', '.js'],
|
|
|
|
alias: {
|
2018-09-12 19:12:44 +02:00
|
|
|
jslib: path.join(__dirname, 'jslib/src'),
|
2018-10-14 05:21:54 +02:00
|
|
|
tldjs: path.join(__dirname, 'jslib/src/misc/tldjs.noop'),
|
2018-09-12 19:12:44 +02:00
|
|
|
},
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
2018-09-12 19:12:44 +02:00
|
|
|
path: path.resolve(__dirname, 'build'),
|
|
|
|
},
|
2018-01-23 19:59:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const main = {
|
2018-09-12 19:12:44 +02:00
|
|
|
mode: 'production',
|
2018-01-23 19:59:01 +01:00
|
|
|
target: 'electron-main',
|
|
|
|
node: {
|
|
|
|
__dirname: false,
|
2018-09-12 19:12:44 +02:00
|
|
|
__filename: false,
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
|
|
|
entry: {
|
2020-12-29 20:53:29 +01:00
|
|
|
'main': './src/entry.ts',
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
2018-09-14 21:55:55 +02:00
|
|
|
optimization: {
|
|
|
|
minimize: false,
|
|
|
|
},
|
2018-01-23 19:59:01 +01:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.node$/,
|
2018-09-12 19:12:44 +02:00
|
|
|
loader: 'node-loader',
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
2018-09-12 19:12:44 +02:00
|
|
|
],
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
|
|
|
plugins: [
|
2021-04-23 10:45:30 +02:00
|
|
|
new CleanWebpackPlugin(),
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
'./src/package.json',
|
|
|
|
{ from: './src/images', to: 'images' },
|
|
|
|
{ from: './src/locales', to: 'locales' },
|
|
|
|
]
|
|
|
|
}),
|
2018-01-23 19:59:01 +01:00
|
|
|
],
|
2018-09-12 19:12:44 +02:00
|
|
|
externals: [nodeExternals()],
|
2018-01-23 19:59:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = merge(common, main);
|