1
0
mirror of https://github.com/bitwarden/browser synced 2024-12-25 09:32:06 +01:00
bitwarden-estensione-browser/apps/cli/webpack.config.js

85 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-12-20 18:04:00 +01:00
const path = require("path");
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const nodeExternals = require("webpack-node-externals");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const config = require("./config/config");
2018-05-15 05:16:59 +02:00
if (process.env.NODE_ENV == null) {
2021-12-20 18:04:00 +01:00
process.env.NODE_ENV = "development";
2018-05-15 05:16:59 +02:00
}
2021-12-20 18:04:00 +01:00
const ENV = (process.env.ENV = process.env.NODE_ENV);
2018-05-15 05:16:59 +02:00
const envConfig = config.load(ENV);
config.log(envConfig);
2018-05-15 05:16:59 +02:00
const moduleRules = [
2021-12-20 18:04:00 +01:00
{
test: /\.ts$/,
use: "ts-loader",
2021-12-20 18:04:00 +01:00
exclude: path.resolve(__dirname, "node_modules"),
},
2018-05-15 05:16:59 +02:00
];
const plugins = [
2021-12-20 18:04:00 +01:00
new CopyWebpackPlugin({
patterns: [{ from: "./src/locales", to: "locales" }],
}),
new webpack.DefinePlugin({
"process.env.BWCLI_ENV": JSON.stringify(ENV),
}),
new webpack.BannerPlugin({
banner: "#!/usr/bin/env node",
raw: true,
}),
new webpack.IgnorePlugin({
resourceRegExp: /^encoding$/,
contextRegExp: /node-fetch/,
}),
new webpack.EnvironmentPlugin({
BWCLI_ENV: ENV,
FLAGS: envConfig.flags,
}),
new webpack.IgnorePlugin({
resourceRegExp: /canvas/,
contextRegExp: /jsdom$/,
}),
2018-05-15 05:16:59 +02:00
];
const webpackConfig = {
2021-12-20 18:04:00 +01:00
mode: ENV,
target: "node",
devtool: ENV === "development" ? "eval-source-map" : "source-map",
node: {
__dirname: false,
__filename: false,
},
entry: {
bw: "./src/bw.ts",
},
optimization: {
minimize: false,
},
resolve: {
extensions: [".ts", ".js"],
symlinks: false,
modules: [path.resolve("../../node_modules")],
2021-12-20 18:04:00 +01:00
plugins: [new TsconfigPathsPlugin({ configFile: "./tsconfig.json" })],
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "build"),
2024-03-12 18:02:47 +01:00
clean: true,
2021-12-20 18:04:00 +01:00
},
module: { rules: moduleRules },
plugins: plugins,
externals: [
nodeExternals({
modulesDir: "../../node_modules",
2022-06-14 17:10:53 +02:00
allowlist: [/@bitwarden/],
}),
],
2018-05-15 05:16:59 +02:00
};
module.exports = webpackConfig;