mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 05:13:29 +00:00
build(browser): integrate nx (#16712)
This commit is contained in:
4
bitwarden_license/bit-browser/tsconfig.build.json
Normal file
4
bitwarden_license/bit-browser/tsconfig.build.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["**/*.stories.*", "**/*.spec.ts"]
|
||||
}
|
||||
@@ -1,13 +1,54 @@
|
||||
const path = require("path");
|
||||
const { buildConfig } = require("../../apps/browser/webpack.base");
|
||||
|
||||
module.exports = buildConfig({
|
||||
configName: "Commercial",
|
||||
popup: {
|
||||
entry: "../../bitwarden_license/bit-browser/src/popup/main.ts",
|
||||
entryModule: "../../bitwarden_license/bit-browser/src/popup/app.module#AppModule",
|
||||
},
|
||||
background: {
|
||||
entry: "../../bitwarden_license/bit-browser/src/platform/background.ts",
|
||||
},
|
||||
tsConfig: "../../bitwarden_license/bit-browser/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: "Commercial",
|
||||
popup: {
|
||||
entry: path.resolve(__dirname, "src/popup/main.ts"),
|
||||
entryModule: "bitwarden_license/bit-browser/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: "Commercial",
|
||||
popup: {
|
||||
entry: path.resolve(__dirname, "src/popup/main.ts"),
|
||||
entryModule: "bitwarden_license/bit-browser/src/popup/app.module#AppModule",
|
||||
},
|
||||
background: {
|
||||
entry: path.resolve(__dirname, "src/platform/background.ts"),
|
||||
},
|
||||
tsConfig: path.resolve(__dirname, "tsconfig.json"),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user