mirror of
https://github.com/bitwarden/browser
synced 2026-02-27 10:03:23 +00:00
- Add project.json with build, serve, test, and lint targets - Support both OSS and Bit configurations via Nx configurations - Maintain backward compatibility with existing npm build scripts - Update webpack configs to work with both Nx and direct webpack CLI calls - Enable nx build cli --configuration=[oss|oss-dev|bit|bit-dev] commands - Enable nx serve cli for development workflow with watch mode - Preserve all existing npm run build:* commands for compatibility
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
|
|
|
|
module.exports = (webpackConfig, context) => {
|
|
// Check if this is being called by Nx or directly by webpack CLI
|
|
const isNxBuild = !!(context && context.options);
|
|
|
|
let config;
|
|
|
|
if (isNxBuild) {
|
|
// Use Nx configuration as base
|
|
const nxConfig = require("../../apps/cli/webpack.nx.config.js");
|
|
config = nxConfig(webpackConfig, context);
|
|
|
|
// Apply bit-cli specific modifications for Nx builds
|
|
config.entry = { bw: context.options.main || "bitwarden_license/bit-cli/src/bw.ts" };
|
|
config.resolve.plugins = [new TsconfigPathsPlugin({ configFile: "tsconfig.base.json" })];
|
|
|
|
// Update the locales path for bit-cli in Nx context
|
|
const copyPlugin = config.plugins.find(
|
|
(plugin) => plugin.constructor.name === "CopyWebpackPlugin",
|
|
);
|
|
if (copyPlugin) {
|
|
copyPlugin.patterns = [{ from: "bitwarden_license/bit-cli/src/locales", to: "locales" }];
|
|
}
|
|
} else {
|
|
// Use npm configuration as base
|
|
const npmConfig = require("../../apps/cli/webpack.npm.config.js");
|
|
config = { ...npmConfig };
|
|
|
|
// Apply bit-cli specific modifications for npm builds
|
|
config.entry = { bw: "../../bitwarden_license/bit-cli/src/bw.ts" };
|
|
config.resolve.plugins = [
|
|
new TsconfigPathsPlugin({ configFile: "../../bitwarden_license/bit-cli/tsconfig.json" }),
|
|
];
|
|
|
|
// Update the locales path for bit-cli (relative to bit-cli directory)
|
|
const copyPlugin = config.plugins.find(
|
|
(plugin) => plugin.constructor.name === "CopyWebpackPlugin",
|
|
);
|
|
if (copyPlugin) {
|
|
copyPlugin.patterns = [{ from: "./src/locales", to: "locales" }];
|
|
}
|
|
}
|
|
|
|
return config;
|
|
};
|