1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-04 13:44:00 +01:00
bitwarden-browser/apps/desktop/webpack.main.js
Bernd Schoolmann 864e6759fd
Switch to rustcrypto argon2 on desktop (#11753)
* Switch to rustcrypto argon2 on desktop

* Make argon2 use zeroize

* Remove argon2 native modules from electron-builder config

* Clean rust implementation of argon2

* Update cargo.lock

* Update apps/desktop/desktop_native/napi/src/lib.rs

Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>

* Add tests

* Clean up test

* Remove argon2 external from webpack main

* Fix build

* Fix argon2 module causing a startup crash

---------

Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
2024-12-04 11:54:55 +00:00

88 lines
2.0 KiB
JavaScript

const path = require("path");
const { merge } = require("webpack-merge");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const configurator = require("./config/config");
const { EnvironmentPlugin } = require("webpack");
const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE_ENV;
console.log("Main process config");
const envConfig = configurator.load(NODE_ENV);
configurator.log(envConfig);
const common = {
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules\/(?!(@bitwarden)\/).*/,
},
],
},
plugins: [],
resolve: {
extensions: [".tsx", ".ts", ".js"],
plugins: [new TsconfigPathsPlugin({ configFile: "./tsconfig.json" })],
},
};
const prod = {
output: {
filename: "[name].js",
path: path.resolve(__dirname, "build"),
},
};
const dev = {
output: {
filename: "[name].js",
path: path.resolve(__dirname, "build"),
devtoolModuleFilenameTemplate: "[absolute-resource-path]",
},
devtool: "cheap-source-map",
};
const main = {
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",
},
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [
"./src/package.json",
{ from: "./src/images", to: "images" },
{ from: "./src/locales", to: "locales" },
],
}),
new EnvironmentPlugin({
FLAGS: envConfig.flags,
DEV_FLAGS: NODE_ENV === "development" ? envConfig.devFlags : {},
}),
],
externals: {
"electron-reload": "commonjs2 electron-reload",
"@bitwarden/desktop-napi": "commonjs2 @bitwarden/desktop-napi",
},
};
module.exports = merge(common, NODE_ENV === "development" ? dev : prod, main);