fleet/webpack.config.js
Scott Gress fcdd01d78d
Add "Require BitLocker PIN" checkbox to disk encryption page (#31132)
for #31064 

# Details

This PR adds a "Require BitLocker PIN" checkbox under a new "Advanced"
section on the Disk Encryption page. This UI will only be visible if:

* "Turn on disk encryption" is checked
* The front-end was compiled using the `SHOW_BITLOCKER_PIN_OPTION=true`
env var, e.g.:
```
SHOW_BITLOCKER_PIN_OPTION=true NODE_ENV=development yarn run webpack --progress --watch
```

See Figma for reference:
https://www.figma.com/design/XbhlPuEJxQtOgTZW9EOJZp/-28133-Enforce-BitLocker-PIN?node-id=5334-1026&t=NuPo1M5fJepyCCRy-0

With encryption off:
<img width="569" height="233" alt="image"
src="https://github.com/user-attachments/assets/558e74cc-ce3d-47e3-aa14-1391e1cb4146"
/>

With encryption on:
<img width="551" height="285" alt="image"
src="https://github.com/user-attachments/assets/adfe2ead-4c5c-43a0-a5aa-9566635aba5f"
/>

Expanded:
<img width="534" height="297" alt="image"
src="https://github.com/user-attachments/assets/ac0620a2-528f-4118-ae46-992a646c97d8"
/>

Tooltip:
<img width="579" height="317" alt="image"
src="https://github.com/user-attachments/assets/23d13820-9bcb-49fb-b32b-2b5c60e7e55c"
/>



# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
   - will add changelog when feature is complete
- [x] Manual QA for all new/changed functionality
2025-07-23 14:36:28 -05:00

156 lines
4.1 KiB
JavaScript

require("es6-promise").polyfill();
const path = require("path");
const webpack = require("webpack");
const bourbon = require("node-bourbon").includePaths;
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const WebpackNotifierPlugin = require("webpack-notifier");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const globImporter = require("node-sass-glob-importer");
const DEV_SOURCE_MAPS = "eval-source-map";
let plugins = [
new ForkTsCheckerWebpackPlugin(),
new HtmlWebpackPlugin({
filename: "../frontend/templates/react.tmpl",
inject: false,
templateParameters: {
isProduction: process.env.NODE_ENV === "production",
},
template: "frontend/templates/react.ejs",
}),
new WebpackNotifierPlugin({
excludeWarnings: true,
}),
new webpack.DefinePlugin({
featureFlags: {
// e.g.: allowGitOpsMode: JSON.stringify(process.env.ALLOW_GITOPS_MODE),
showBitLockerPINOption: JSON.stringify(
process.env.SHOW_BITLOCKER_PIN_OPTION
),
},
}),
];
if (process.env.NODE_ENV === "production") {
plugins = plugins.concat([
new webpack.DefinePlugin({
"process.env": { NODE_ENV: JSON.stringify("production") },
}),
new MiniCssExtractPlugin({
filename: "bundle-[contenthash].css",
}),
]);
} else {
// development
plugins = plugins.concat([
new MiniCssExtractPlugin({ filename: "bundle.css" }),
]);
}
const repo = __dirname;
const config = {
mode: process.env.NODE_ENV,
entry: {
bundle: path.join(repo, "frontend/index.jsx"),
},
output: {
path: path.join(repo, "assets/"),
publicPath: "/assets/",
filename: "[name].js",
},
devtool: process.env.NODE_ENV === "development" ? DEV_SOURCE_MAPS : false,
plugins,
optimization: {
minimize: process.env.NODE_ENV === "production",
},
module: {
// The following noParse suppresses the warning about sqlite-parser being a
// pre-compiled JS file. See https://goo.gl/N4s6bB.
noParse: /node_modules\/sqlite-parser\/dist\/sqlite-parser-min.js/,
rules: [
{
test: /\.(pdf|png|gif|ico|jpg|svg|eot|otf|woff|woff2|ttf|mp4|webm)$/,
type: "asset",
generator: {
filename: "[name]@[hash][ext]",
},
},
{
test: /\.(sh|ps1)$/,
type: "asset/source",
},
{
test: /(\.tsx?|\.jsx?)$/,
exclude: /node_modules/,
use: {
loader: "esbuild-loader",
options: {
loader: "tsx", // Or 'ts' if you don't need tsx
target: "es2016",
},
},
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: "./",
},
},
{ loader: "css-loader" },
{ loader: "postcss-loader" },
{
loader: "sass-loader",
options: {
sourceMap: true,
sassOptions: {
includePaths: bourbon,
importer: globImporter(),
},
},
},
],
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {},
},
"css-loader",
"postcss-loader",
],
},
{
test: /\.jsx?$/,
include: path.join(repo, "frontend"),
use: { loader: "babel-loader", options: { cacheDirectory: true } },
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".jsx", ".json"],
modules: [path.resolve(path.join(repo, "./frontend")), "node_modules"],
fallback: { path: require.resolve("path-browserify") },
alias: {
"node-sql-parser": path.resolve(
__dirname,
"node_modules/node-sql-parser/umd/sqlite.umd.js"
),
},
},
};
if (process.env.NODE_ENV === "production") {
config.output.filename = "[name]-[contenthash].js";
}
module.exports = config;