mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
build(browser): integrate nx (#16712)
This commit is contained in:
494
apps/browser/project.json
Normal file
494
apps/browser/project.json
Normal file
@@ -0,0 +1,494 @@
|
||||
{
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"name": "browser",
|
||||
"projectType": "application",
|
||||
"sourceRoot": "apps/browser/src",
|
||||
"tags": ["scope:browser", "type:app"],
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/webpack:webpack",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"defaultConfiguration": "chrome-dev",
|
||||
"options": {
|
||||
"outputPath": "dist/apps/browser",
|
||||
"webpackConfig": "apps/browser/webpack.config.js",
|
||||
"tsConfig": "apps/browser/tsconfig.build.json",
|
||||
"main": "apps/browser/src/popup/main.ts",
|
||||
"target": "web",
|
||||
"compiler": "tsc"
|
||||
},
|
||||
"configurations": {
|
||||
"chrome": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/chrome",
|
||||
"env": {
|
||||
"BROWSER": "chrome",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"chrome-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/chrome-dev",
|
||||
"env": {
|
||||
"BROWSER": "chrome",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"edge": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/edge",
|
||||
"env": {
|
||||
"BROWSER": "edge",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"edge-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/edge-dev",
|
||||
"env": {
|
||||
"BROWSER": "edge",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"firefox": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/firefox",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"firefox-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/firefox-dev",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"firefox-mv2": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/firefox-mv2",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"firefox-mv2-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/firefox-mv2-dev",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"opera": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/opera",
|
||||
"env": {
|
||||
"BROWSER": "opera",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"opera-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/opera-dev",
|
||||
"env": {
|
||||
"BROWSER": "opera",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"safari": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/safari",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"safari-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/safari-dev",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"safari-mv2": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/safari-mv2",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"safari-mv2-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/safari-mv2-dev",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-chrome": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/commercial-chrome",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "chrome",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"commercial-chrome-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-chrome-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "chrome",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-edge": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/commercial-edge",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "edge",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"commercial-edge-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-edge-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "edge",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-firefox": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/commercial-firefox",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"commercial-firefox-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-firefox-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-firefox-mv2": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/commercial-firefox-mv2",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"commercial-firefox-mv2-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-firefox-mv2-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-opera": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/commercial-opera",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "opera",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"commercial-opera-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-opera-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "opera",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-safari": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/commercial-safari",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"commercial-safari-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-safari-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-safari-mv2": {
|
||||
"mode": "production",
|
||||
"outputPath": "dist/apps/browser/commercial-safari-mv2",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
},
|
||||
"commercial-safari-mv2-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-safari-mv2-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"executor": "@nx/webpack:webpack",
|
||||
"defaultConfiguration": "chrome-dev",
|
||||
"options": {
|
||||
"outputPath": "dist/apps/browser",
|
||||
"webpackConfig": "apps/browser/webpack.config.js",
|
||||
"tsConfig": "apps/browser/tsconfig.build.json",
|
||||
"main": "apps/browser/src/popup/main.ts",
|
||||
"target": "web",
|
||||
"compiler": "tsc",
|
||||
"watch": true
|
||||
},
|
||||
"configurations": {
|
||||
"chrome-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/chrome-dev",
|
||||
"env": {
|
||||
"BROWSER": "chrome",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"firefox-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/firefox-dev",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"firefox-mv2-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/firefox-mv2-dev",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"safari-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/safari-dev",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"safari-mv2-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/safari-mv2-dev",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"edge-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/edge-dev",
|
||||
"env": {
|
||||
"BROWSER": "edge",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"opera-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/opera-dev",
|
||||
"env": {
|
||||
"BROWSER": "opera",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-chrome-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-chrome-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "chrome",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-firefox-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-firefox-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-firefox-mv2-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-firefox-mv2-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "firefox",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-safari-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-safari-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-safari-mv2-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-safari-mv2-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "safari",
|
||||
"MANIFEST_VERSION": "2",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-edge-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-edge-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "edge",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
},
|
||||
"commercial-opera-dev": {
|
||||
"mode": "development",
|
||||
"outputPath": "dist/apps/browser/commercial-opera-dev",
|
||||
"webpackConfig": "bitwarden_license/bit-browser/webpack.config.js",
|
||||
"main": "bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
"tsConfig": "bitwarden_license/bit-browser/tsconfig.build.json",
|
||||
"env": {
|
||||
"BROWSER": "opera",
|
||||
"MANIFEST_VERSION": "3",
|
||||
"NODE_ENV": "development"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nx/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||
"options": {
|
||||
"jestConfig": "apps/browser/jest.config.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["apps/browser/**/*.ts", "apps/browser/**/*.html"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
5
apps/browser/tsconfig.build.json
Normal file
5
apps/browser/tsconfig.build.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["src", "../../libs/common/src/autofill/constants"],
|
||||
"exclude": ["**/*.stories.*", "**/*.spec.ts"]
|
||||
}
|
||||
@@ -4,5 +4,6 @@
|
||||
"src",
|
||||
"../../libs/common/src/autofill/constants",
|
||||
"../../libs/common/custom-matchers.d.ts"
|
||||
]
|
||||
],
|
||||
"exclude": ["**/*.stories.*"]
|
||||
}
|
||||
|
||||
@@ -10,14 +10,18 @@ const configurator = require("./config/config");
|
||||
const manifest = require("./webpack/manifest");
|
||||
const AngularCheckPlugin = require("./webpack/angular-check");
|
||||
|
||||
module.exports.getEnv = function getEnv() {
|
||||
const ENV = (process.env.ENV = process.env.NODE_ENV);
|
||||
module.exports.getEnv = function getEnv(params) {
|
||||
const ENV = params.env || (process.env.ENV = process.env.NODE_ENV);
|
||||
const manifestVersion = process.env.MANIFEST_VERSION == 3 ? 3 : 2;
|
||||
const browser = process.env.BROWSER ?? "chrome";
|
||||
|
||||
return { ENV, manifestVersion, browser };
|
||||
};
|
||||
|
||||
const DEFAULT_PARAMS = {
|
||||
outputPath: path.resolve(__dirname, "build"),
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* configName: string;
|
||||
@@ -29,15 +33,20 @@ module.exports.getEnv = function getEnv() {
|
||||
* entry: string;
|
||||
* };
|
||||
* tsConfig: string;
|
||||
* outputPath?: string;
|
||||
* mode?: string;
|
||||
* env?: string;
|
||||
* additionalEntries?: { [outputPath: string]: string }
|
||||
* }} params - The input parameters for building the config.
|
||||
*/
|
||||
module.exports.buildConfig = function buildConfig(params) {
|
||||
params = { ...DEFAULT_PARAMS, ...params };
|
||||
|
||||
if (process.env.NODE_ENV == null) {
|
||||
process.env.NODE_ENV = "development";
|
||||
}
|
||||
|
||||
const { ENV, manifestVersion, browser } = module.exports.getEnv();
|
||||
const { ENV, manifestVersion, browser } = module.exports.getEnv(params);
|
||||
|
||||
console.log(`Building Manifest Version ${manifestVersion} app - ${params.configName} version`);
|
||||
|
||||
@@ -103,7 +112,7 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
{
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
configFile: "../../babel.config.json",
|
||||
configFile: path.resolve(__dirname, "../../babel.config.json"),
|
||||
cacheDirectory: ENV === "development",
|
||||
compact: ENV !== "development",
|
||||
},
|
||||
@@ -130,43 +139,52 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
|
||||
const plugins = [
|
||||
new HtmlWebpackPlugin({
|
||||
template: "./src/popup/index.ejs",
|
||||
template: path.resolve(__dirname, "src/popup/index.ejs"),
|
||||
filename: "popup/index.html",
|
||||
chunks: ["popup/polyfills", "popup/vendor-angular", "popup/vendor", "popup/main"],
|
||||
browser: browser,
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: "./src/autofill/notification/bar.html",
|
||||
template: path.resolve(__dirname, "src/autofill/notification/bar.html"),
|
||||
filename: "notification/bar.html",
|
||||
chunks: ["notification/bar"],
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: "./src/autofill/overlay/inline-menu/pages/button/button.html",
|
||||
template: path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/overlay/inline-menu/pages/button/button.html",
|
||||
),
|
||||
filename: "overlay/menu-button.html",
|
||||
chunks: ["overlay/menu-button"],
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: "./src/autofill/overlay/inline-menu/pages/list/list.html",
|
||||
template: path.resolve(__dirname, "src/autofill/overlay/inline-menu/pages/list/list.html"),
|
||||
filename: "overlay/menu-list.html",
|
||||
chunks: ["overlay/menu-list"],
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: "./src/autofill/overlay/inline-menu/pages/menu-container/menu-container.html",
|
||||
template: path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/overlay/inline-menu/pages/menu-container/menu-container.html",
|
||||
),
|
||||
filename: "overlay/menu.html",
|
||||
chunks: ["overlay/menu"],
|
||||
}),
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: manifestVersion == 3 ? "./src/manifest.v3.json" : "./src/manifest.json",
|
||||
from:
|
||||
manifestVersion == 3
|
||||
? path.resolve(__dirname, "src/manifest.v3.json")
|
||||
: path.resolve(__dirname, "src/manifest.json"),
|
||||
to: "manifest.json",
|
||||
transform: manifest.transform(browser),
|
||||
},
|
||||
{ from: "./src/managed_schema.json", to: "managed_schema.json" },
|
||||
{ from: "./src/_locales", to: "_locales" },
|
||||
{ from: "./src/images", to: "images" },
|
||||
{ from: "./src/popup/images", to: "popup/images" },
|
||||
{ from: "./src/autofill/content/autofill.css", to: "content" },
|
||||
{ from: path.resolve(__dirname, "src/managed_schema.json"), to: "managed_schema.json" },
|
||||
{ from: path.resolve(__dirname, "src/_locales"), to: "_locales" },
|
||||
{ from: path.resolve(__dirname, "src/images"), to: "images" },
|
||||
{ from: path.resolve(__dirname, "src/popup/images"), to: "popup/images" },
|
||||
{ from: path.resolve(__dirname, "src/autofill/content/autofill.css"), to: "content" },
|
||||
],
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
@@ -196,33 +214,76 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
name: "main",
|
||||
mode: ENV,
|
||||
devtool: false,
|
||||
|
||||
entry: {
|
||||
"popup/polyfills": "./src/popup/polyfills.ts",
|
||||
"popup/polyfills": path.resolve(__dirname, "src/popup/polyfills.ts"),
|
||||
"popup/main": params.popup.entry,
|
||||
"content/trigger-autofill-script-injection":
|
||||
"./src/autofill/content/trigger-autofill-script-injection.ts",
|
||||
"content/bootstrap-autofill": "./src/autofill/content/bootstrap-autofill.ts",
|
||||
"content/bootstrap-autofill-overlay": "./src/autofill/content/bootstrap-autofill-overlay.ts",
|
||||
"content/bootstrap-autofill-overlay-menu":
|
||||
"./src/autofill/content/bootstrap-autofill-overlay-menu.ts",
|
||||
"content/bootstrap-autofill-overlay-notifications":
|
||||
"./src/autofill/content/bootstrap-autofill-overlay-notifications.ts",
|
||||
"content/autofiller": "./src/autofill/content/autofiller.ts",
|
||||
"content/auto-submit-login": "./src/autofill/content/auto-submit-login.ts",
|
||||
"content/contextMenuHandler": "./src/autofill/content/context-menu-handler.ts",
|
||||
"content/content-message-handler": "./src/autofill/content/content-message-handler.ts",
|
||||
"content/fido2-content-script": "./src/autofill/fido2/content/fido2-content-script.ts",
|
||||
"content/fido2-page-script": "./src/autofill/fido2/content/fido2-page-script.ts",
|
||||
"content/ipc-content-script": "./src/platform/ipc/content/ipc-content-script.ts",
|
||||
"notification/bar": "./src/autofill/notification/bar.ts",
|
||||
"overlay/menu-button":
|
||||
"./src/autofill/overlay/inline-menu/pages/button/bootstrap-autofill-inline-menu-button.ts",
|
||||
"overlay/menu-list":
|
||||
"./src/autofill/overlay/inline-menu/pages/list/bootstrap-autofill-inline-menu-list.ts",
|
||||
"overlay/menu":
|
||||
"./src/autofill/overlay/inline-menu/pages/menu-container/bootstrap-autofill-inline-menu-container.ts",
|
||||
"content/send-on-installed-message": "./src/vault/content/send-on-installed-message.ts",
|
||||
"content/send-popup-open-message": "./src/vault/content/send-popup-open-message.ts",
|
||||
"content/trigger-autofill-script-injection": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/content/trigger-autofill-script-injection.ts",
|
||||
),
|
||||
"content/bootstrap-autofill": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/content/bootstrap-autofill.ts",
|
||||
),
|
||||
"content/bootstrap-autofill-overlay": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/content/bootstrap-autofill-overlay.ts",
|
||||
),
|
||||
"content/bootstrap-autofill-overlay-menu": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/content/bootstrap-autofill-overlay-menu.ts",
|
||||
),
|
||||
"content/bootstrap-autofill-overlay-notifications": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/content/bootstrap-autofill-overlay-notifications.ts",
|
||||
),
|
||||
"content/autofiller": path.resolve(__dirname, "src/autofill/content/autofiller.ts"),
|
||||
"content/auto-submit-login": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/content/auto-submit-login.ts",
|
||||
),
|
||||
"content/contextMenuHandler": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/content/context-menu-handler.ts",
|
||||
),
|
||||
"content/content-message-handler": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/content/content-message-handler.ts",
|
||||
),
|
||||
"content/fido2-content-script": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/fido2/content/fido2-content-script.ts",
|
||||
),
|
||||
"content/fido2-page-script": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/fido2/content/fido2-page-script.ts",
|
||||
),
|
||||
"content/ipc-content-script": path.resolve(
|
||||
__dirname,
|
||||
"src/platform/ipc/content/ipc-content-script.ts",
|
||||
),
|
||||
"notification/bar": path.resolve(__dirname, "src/autofill/notification/bar.ts"),
|
||||
"overlay/menu-button": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/overlay/inline-menu/pages/button/bootstrap-autofill-inline-menu-button.ts",
|
||||
),
|
||||
"overlay/menu-list": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/overlay/inline-menu/pages/list/bootstrap-autofill-inline-menu-list.ts",
|
||||
),
|
||||
"overlay/menu": path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/overlay/inline-menu/pages/menu-container/bootstrap-autofill-inline-menu-container.ts",
|
||||
),
|
||||
"content/send-on-installed-message": path.resolve(
|
||||
__dirname,
|
||||
"src/vault/content/send-on-installed-message.ts",
|
||||
),
|
||||
"content/send-popup-open-message": path.resolve(
|
||||
__dirname,
|
||||
"src/vault/content/send-popup-open-message.ts",
|
||||
),
|
||||
...params.additionalEntries,
|
||||
},
|
||||
cache:
|
||||
@@ -291,7 +352,7 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
resolve: {
|
||||
extensions: [".ts", ".js"],
|
||||
symlinks: false,
|
||||
modules: [path.resolve("../../node_modules")],
|
||||
modules: [path.resolve(__dirname, "../../node_modules")],
|
||||
fallback: {
|
||||
assert: false,
|
||||
buffer: require.resolve("buffer/"),
|
||||
@@ -306,7 +367,7 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
filename: "[name].js",
|
||||
chunkFilename: "assets/[name].js",
|
||||
webassemblyModuleFilename: "assets/[modulehash].wasm",
|
||||
path: path.resolve(__dirname, "build"),
|
||||
path: params.outputPath,
|
||||
clean: true,
|
||||
},
|
||||
module: {
|
||||
@@ -335,7 +396,7 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
// Manifest V2 uses Background Pages which requires a html page.
|
||||
mainConfig.plugins.push(
|
||||
new HtmlWebpackPlugin({
|
||||
template: "./src/platform/background.html",
|
||||
template: path.resolve(__dirname, "src/platform/background.html"),
|
||||
filename: "background.html",
|
||||
chunks: ["vendor", "background"],
|
||||
}),
|
||||
@@ -344,19 +405,23 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
// Manifest V2 background pages can be run through the regular build pipeline.
|
||||
// Since it's a standard webpage.
|
||||
mainConfig.entry.background = params.background.entry;
|
||||
mainConfig.entry["content/fido2-page-script-delay-append-mv2"] =
|
||||
"./src/autofill/fido2/content/fido2-page-script-delay-append.mv2.ts";
|
||||
mainConfig.entry["content/fido2-page-script-delay-append-mv2"] = path.resolve(
|
||||
__dirname,
|
||||
"src/autofill/fido2/content/fido2-page-script-delay-append.mv2.ts",
|
||||
);
|
||||
|
||||
configs.push(mainConfig);
|
||||
} else {
|
||||
// Firefox does not use the offscreen API
|
||||
if (browser !== "firefox") {
|
||||
mainConfig.entry["offscreen-document/offscreen-document"] =
|
||||
"./src/platform/offscreen-document/offscreen-document.ts";
|
||||
mainConfig.entry["offscreen-document/offscreen-document"] = path.resolve(
|
||||
__dirname,
|
||||
"src/platform/offscreen-document/offscreen-document.ts",
|
||||
);
|
||||
|
||||
mainConfig.plugins.push(
|
||||
new HtmlWebpackPlugin({
|
||||
template: "./src/platform/offscreen-document/index.html",
|
||||
template: path.resolve(__dirname, "src/platform/offscreen-document/index.html"),
|
||||
filename: "offscreen-document/index.html",
|
||||
chunks: ["offscreen-document/offscreen-document"],
|
||||
}),
|
||||
@@ -372,11 +437,12 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
name: "background",
|
||||
mode: ENV,
|
||||
devtool: false,
|
||||
|
||||
entry: params.background.entry,
|
||||
target: target,
|
||||
output: {
|
||||
filename: "background.js",
|
||||
path: path.resolve(__dirname, "build"),
|
||||
path: params.outputPath,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
@@ -409,7 +475,7 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
resolve: {
|
||||
extensions: [".ts", ".js"],
|
||||
symlinks: false,
|
||||
modules: [path.resolve("../../node_modules")],
|
||||
modules: [path.resolve(__dirname, "../../node_modules")],
|
||||
plugins: [new TsconfigPathsPlugin()],
|
||||
fallback: {
|
||||
fs: false,
|
||||
@@ -428,8 +494,11 @@ module.exports.buildConfig = function buildConfig(params) {
|
||||
backgroundConfig.plugins.push(
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{ from: "./src/safari/mv3/fake-background.html", to: "background.html" },
|
||||
{ from: "./src/safari/mv3/fake-vendor.js", to: "vendor.js" },
|
||||
{
|
||||
from: path.resolve(__dirname, "src/safari/mv3/fake-background.html"),
|
||||
to: "background.html",
|
||||
},
|
||||
{ from: path.resolve(__dirname, "src/safari/mv3/fake-vendor.js"), to: "vendor.js" },
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -1,13 +1,54 @@
|
||||
const path = require("path");
|
||||
const { buildConfig } = require("./webpack.base");
|
||||
|
||||
module.exports = buildConfig({
|
||||
configName: "OSS",
|
||||
popup: {
|
||||
entry: "./src/popup/main.ts",
|
||||
entryModule: "src/popup/app.module#AppModule",
|
||||
},
|
||||
background: {
|
||||
entry: "./src/platform/background.ts",
|
||||
},
|
||||
tsConfig: "tsconfig.json",
|
||||
});
|
||||
module.exports = (webpackConfig, context) => {
|
||||
// Detect if called by Nx (context parameter exists)
|
||||
const isNxBuild = context && context.options;
|
||||
|
||||
if (isNxBuild) {
|
||||
// Nx build configuration
|
||||
const mode = context.options.mode || "development";
|
||||
if (process.env.NODE_ENV == null) {
|
||||
process.env.NODE_ENV = mode;
|
||||
}
|
||||
const ENV = (process.env.ENV = process.env.NODE_ENV);
|
||||
|
||||
// Set environment variables from Nx context
|
||||
if (context.options.env) {
|
||||
Object.keys(context.options.env).forEach((key) => {
|
||||
process.env[key] = context.options.env[key];
|
||||
});
|
||||
}
|
||||
|
||||
return buildConfig({
|
||||
configName: "OSS",
|
||||
popup: {
|
||||
entry: path.resolve(__dirname, "src/popup/main.ts"),
|
||||
entryModule: "src/popup/app.module#AppModule",
|
||||
},
|
||||
background: {
|
||||
entry: path.resolve(__dirname, "src/platform/background.ts"),
|
||||
},
|
||||
tsConfig: path.resolve(__dirname, "tsconfig.build.json"),
|
||||
outputPath:
|
||||
context.context && context.context.root
|
||||
? path.resolve(context.context.root, context.options.outputPath)
|
||||
: context.options.outputPath,
|
||||
mode: mode,
|
||||
env: ENV,
|
||||
});
|
||||
} else {
|
||||
// npm build configuration
|
||||
return buildConfig({
|
||||
configName: "OSS",
|
||||
popup: {
|
||||
entry: path.resolve(__dirname, "src/popup/main.ts"),
|
||||
entryModule: "src/popup/app.module#AppModule",
|
||||
},
|
||||
background: {
|
||||
entry: path.resolve(__dirname, "src/platform/background.ts"),
|
||||
},
|
||||
tsConfig: "tsconfig.json",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user