1
0
mirror of https://github.com/bitwarden/web synced 2026-01-05 18:13:41 +00:00

WIP angular cli

This commit is contained in:
Hinton
2022-01-25 20:06:29 +01:00
parent f387a4d469
commit 17f5cf74b5
101 changed files with 23671 additions and 3553 deletions

111
extra-webpack.config.ts Normal file
View File

@@ -0,0 +1,111 @@
import { CustomWebpackBrowserSchema, TargetOptions } from "@angular-builders/custom-webpack";
import * as webpack from "webpack";
import * as CopyPlugin from "copy-webpack-plugin";
import * as HtmlWebpackPlugin from "html-webpack-plugin";
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
// We need to extend the default angular webpack to support web vault specific logic.
//
// Namely:
// * Connectors
// * Environment variables
export default (
config: webpack.Configuration,
options: CustomWebpackBrowserSchema,
targetOptions: TargetOptions
) => {
const plugins = [
new HtmlWebpackPlugin({
template: "./src/connectors/duo.html",
filename: "duo-connector.html",
chunks: ["connectors/duo"],
}),
new HtmlWebpackPlugin({
template: "./src/connectors/webauthn.html",
filename: "webauthn-connector.html",
chunks: ["connectors/webauthn"],
}),
new HtmlWebpackPlugin({
template: "./src/connectors/webauthn-mobile.html",
filename: "webauthn-mobile-connector.html",
chunks: ["connectors/webauthn"],
}),
new HtmlWebpackPlugin({
template: "./src/connectors/webauthn-fallback.html",
filename: "webauthn-fallback-connector.html",
chunks: ["connectors/webauthn-fallback"],
}),
new HtmlWebpackPlugin({
template: "./src/connectors/sso.html",
filename: "sso-connector.html",
chunks: ["connectors/sso"],
}),
new HtmlWebpackPlugin({
template: "./src/connectors/captcha.html",
filename: "captcha-connector.html",
chunks: ["connectors/captcha"],
}),
new HtmlWebpackPlugin({
template: "./src/connectors/captcha-mobile.html",
filename: "captcha-mobile-connector.html",
chunks: ["connectors/captcha"],
}),
// TODO: Replace with angular cli copy
new CopyPlugin({
patterns: [
{ from: "./src/.nojekyll" },
{ from: "./src/manifest.json" },
{ from: "./src/favicon.ico" },
{ from: "./src/browserconfig.xml" },
{ from: "./src/app-id.json" },
{ from: "./src/404.html" },
{ from: "./src/404", to: "404" },
{ from: "./src/images", to: "images" },
{ from: "./src/locales", to: "locales" },
{ from: "./node_modules/qrious/dist/qrious.min.js", to: "scripts" },
{ from: "./node_modules/braintree-web-drop-in/dist/browser/dropin.js", to: "scripts" },
{
from: "./src/version.json",
transform(content, path) {
return content.toString().replace("process.env.APPLICATION_VERSION", "12");
},
},
],
}),
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
chunkFilename: "[id].[contenthash].css",
}),
new webpack.EnvironmentPlugin({
ENV: "development",
NODE_ENV: "development",
APPLICATION_VERSION: "123",
CACHE_TAG: Math.random().toString(36).substring(7),
URLS: {},
STRIPE_KEY: "",
BRAINTREE_KEY: "",
PAYPAL_CONFIG: {},
}),
new webpack.ProvidePlugin({
process: "process/browser",
}),
];
config.plugins?.push(...plugins);
(config.resolve as any).fallback = {
buffer: false,
util: require.resolve("util/"),
assert: false,
};
// TODO: Figure out if we have to cast it to any
(config.entry as any)["connectors/webauthn"] = ["./src/connectors/webauthn.ts"];
(config.entry as any)["connectors/webauthn-fallback"] = ["./src/connectors/webauthn-fallback.ts"];
(config.entry as any)["connectors/duo"] = ["./src/connectors/duo.ts"];
(config.entry as any)["connectors/sso"] = ["./src/connectors/sso.ts"];
(config.entry as any)["connectors/captcha"] = ["./src/connectors/captcha.ts"];
return config;
};