2021-12-20 15:47:17 +01:00
|
|
|
const path = require("path");
|
|
|
|
const { merge } = require("webpack-merge");
|
|
|
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
|
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
|
|
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
|
2018-01-23 19:59:01 +01:00
|
|
|
|
2021-12-20 15:47:17 +01:00
|
|
|
const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE_ENV;
|
2021-06-10 18:50:59 +02:00
|
|
|
|
2018-01-23 19:59:01 +01:00
|
|
|
const common = {
|
2021-12-20 15:47:17 +01:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: "ts-loader",
|
|
|
|
exclude: /node_modules\/(?!(@bitwarden)\/).*/,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
plugins: [],
|
|
|
|
resolve: {
|
|
|
|
extensions: [".tsx", ".ts", ".js"],
|
|
|
|
plugins: [new TsconfigPathsPlugin({ configFile: "./tsconfig.json" })],
|
|
|
|
},
|
2021-06-10 18:50:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const prod = {
|
2021-12-20 15:47:17 +01:00
|
|
|
output: {
|
|
|
|
filename: "[name].js",
|
|
|
|
path: path.resolve(__dirname, "build"),
|
|
|
|
},
|
2021-06-10 18:50:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const dev = {
|
2021-12-20 15:47:17 +01:00
|
|
|
output: {
|
|
|
|
filename: "[name].js",
|
|
|
|
path: path.resolve(__dirname, "build"),
|
|
|
|
devtoolModuleFilenameTemplate: "[absolute-resource-path]",
|
|
|
|
},
|
|
|
|
devtool: "cheap-source-map",
|
|
|
|
};
|
2018-01-23 19:59:01 +01:00
|
|
|
|
|
|
|
const main = {
|
2021-12-20 15:47:17 +01:00
|
|
|
mode: NODE_ENV,
|
|
|
|
target: "electron-main",
|
|
|
|
node: {
|
|
|
|
__dirname: false,
|
|
|
|
__filename: false,
|
|
|
|
},
|
|
|
|
entry: {
|
|
|
|
main: "./src/entry.ts",
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
minimize: false,
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.node$/,
|
|
|
|
loader: "node-loader",
|
|
|
|
},
|
2018-01-23 19:59:01 +01:00
|
|
|
],
|
2021-12-20 15:47:17 +01:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin(),
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
"./src/package.json",
|
|
|
|
{ from: "./src/images", to: "images" },
|
|
|
|
{ from: "./src/locales", to: "locales" },
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
2022-01-12 11:32:02 +01:00
|
|
|
externals: {
|
|
|
|
"electron-reload": "commonjs2 electron-reload",
|
2022-01-13 10:46:33 +01:00
|
|
|
"@nodert-win10-rs4/windows.security.credentials.ui":
|
|
|
|
"commonjs2 @nodert-win10-rs4/windows.security.credentials.ui",
|
|
|
|
forcefocus: "commonjs2 forcefocus",
|
2022-05-03 11:03:21 +02:00
|
|
|
keytar: "commonjs2 keytar",
|
2022-01-12 11:32:02 +01:00
|
|
|
},
|
2018-01-23 19:59:01 +01:00
|
|
|
};
|
|
|
|
|
2021-12-20 15:47:17 +01:00
|
|
|
module.exports = merge(common, NODE_ENV === "development" ? dev : prod, main);
|