fleet/webpack.config.js
jacobshandling b990b3c6d9
UI - GitOps Mode, 3/3 (#26537)
## For #26229 

- Remove feature flag
- Undo updates to 4 Policies automation modals to facilitate refactor
being implemented in parallel
- Remaining specs:

**Manage teams:**

![manage-teams](https://github.com/user-attachments/assets/af8d8d10-2add-4d8d-8961-61d0de44b067)

Empty:
<img width="1464" alt="Screenshot 2025-02-21 at 4 27 30 PM"
src="https://github.com/user-attachments/assets/17cf4fc2-cc4e-4f63-8276-3db79b44e9e1"
/>

**Team users:**

![team-users](https://github.com/user-attachments/assets/1bf106c1-bdf7-442c-a957-6c9eea6af14d)
Empty:
<img width="1464" alt="Screenshot 2025-02-21 at 4 29 01 PM"
src="https://github.com/user-attachments/assets/46dd0e44-2af3-4ca7-a0be-628e358a61d7"
/>

**Team agent options:**

![team-agent-options](https://github.com/user-attachments/assets/7d4ee8b6-03c7-48d2-8337-b2c33e50abe9)

**Team settings:**

![team-settings](https://github.com/user-attachments/assets/a67b45fc-a5ce-4267-b8fd-2f1e300d1fd8)


- [x] Changes file added for user-visible changes in `changes/`
- [x] Added/updated automated tests
- [ ] A detailed QA plan exists on the associated ticket (if it isn't
there, work with the product group's QA engineer to add it)
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <[email protected]>
2025-02-21 16:56:20 -08:00

147 lines
3.8 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),
},
}),
];
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") },
},
};
if (process.env.NODE_ENV === "production") {
config.output.filename = "[name]-[contenthash].js";
}
module.exports = config;