bitwarden-estensione-browser/webpack.main.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

88 lines
2.0 KiB
JavaScript
Raw Normal View History

2018-01-23 19:59:01 +01:00
const path = require("path");
const { merge } = require("webpack-merge");
2018-01-23 19:59:01 +01:00
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
const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE_ENV;
2018-01-23 19:59:01 +01:00
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"],
plugins: [new TsconfigPathsPlugin({ configFile: "./tsconfig.json" })],
2018-01-23 19:59:01 +01:00
},
};
const prod = {
output: {
filename: "[name].js",
path: path.resolve(__dirname, "build"),
},
};
const dev = {
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"),
devtoolModuleFilenameTemplate: "[absolute-resource-path]",
2018-09-12 19:12:44 +02:00
},
devtool: "cheap-source-map",
};
2018-01-23 19:59:01 +01:00
const main = {
mode: NODE_ENV,
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
],
2021-12-20 15:47:17 +01:00
},
2018-01-23 19:59:01 +01:00
plugins: [
new CleanWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
"./src/package.json",
{ from: "./src/images", to: "images" },
{ from: "./src/locales", to: "locales" },
2021-12-20 15:47:17 +01:00
],
}),
],
externals: {
"electron-reload": "commonjs2 electron-reload",
"@nodert-win10-rs4/windows.security.credentials.ui":
"commonjs2 @nodert-win10-rs4/windows.security.credentials.ui",
forcefocus: "commonjs2 forcefocus",
keytar: "commonjs2 keytar",
},
2018-01-23 19:59:01 +01:00
};
module.exports = merge(common, NODE_ENV === "development" ? dev : prod, main);