github.com/argoproj/argo-cd/v3@v3.2.1/ui/src/app/webpack.config.js (about)

     1  'use strict;';
     2  
     3  const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
     4  const CopyWebpackPlugin = require('copy-webpack-plugin');
     5  const HtmlWebpackPlugin = require('html-webpack-plugin');
     6  const {codecovWebpackPlugin} = require("@codecov/webpack-plugin");
     7  const webpack = require('webpack');
     8  
     9  const isProd = process.env.NODE_ENV === 'production';
    10  
    11  console.log(`Bundling in ${isProd ? 'production' : 'development'}...`);
    12  
    13  const proxyConf = {
    14      target: process.env.ARGOCD_API_URL || 'http://localhost:8080',
    15      secure: false
    16  };
    17  
    18  const config = {
    19      entry: './src/app/index.tsx',
    20      output: {
    21          filename: '[name].[contenthash].js',
    22          chunkFilename: '[name].[contenthash].chunk.js',
    23          path: __dirname + '/../../dist/app'
    24      },
    25  
    26      resolve: {
    27          extensions: ['.ts', '.tsx', '.js', '.json'],
    28          alias: { react: require.resolve('react') },
    29          fallback: { fs: false }
    30      },
    31      ignoreWarnings: [{
    32          module: new RegExp('/node_modules/argo-ui/.*')
    33      }],
    34      module: {
    35          rules: [
    36              {
    37                  test: /\.tsx?$/,
    38                  loader: 'esbuild-loader',
    39                  options: {
    40                      loader: 'tsx',
    41                      target: 'es2015',
    42                      tsconfigRaw: require('./tsconfig.json')
    43                  }
    44              },
    45              {
    46                  enforce: 'pre',
    47                  exclude: [/node_modules\/react-paginate/, /node_modules\/monaco-editor/],
    48                  test: /\.js$/,
    49                  use: ['esbuild-loader'],
    50              },
    51              {
    52                  test: /\.scss$/,
    53                  use: ['style-loader', 'raw-loader', 'sass-loader']
    54              },
    55              {
    56                  test: /\.css$/,
    57                  use: ['style-loader', 'raw-loader']
    58              }
    59          ]
    60      },
    61      plugins: [
    62          new webpack.DefinePlugin({
    63              'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
    64              'process.env.NODE_ONLINE_ENV': JSON.stringify(process.env.NODE_ONLINE_ENV || 'offline'),
    65              'process.env.HOST_ARCH': JSON.stringify(process.env.HOST_ARCH || 'amd64'),
    66              'process.platform': JSON.stringify('browser'),
    67              'SYSTEM_INFO': JSON.stringify({
    68                  version: process.env.ARGO_VERSION || 'latest'
    69              })
    70          }),
    71          new HtmlWebpackPlugin({ template: 'src/app/index.html' }),
    72          new CopyWebpackPlugin({
    73              patterns: [{
    74                      from: 'src/assets',
    75                      to: 'assets'
    76                  },
    77                  {
    78                      from: 'node_modules/argo-ui/src/assets',
    79                      to: 'assets'
    80                  },
    81                  {
    82                      from: 'node_modules/@fortawesome/fontawesome-free/webfonts',
    83                      to: 'assets/fonts'
    84                  },
    85                  {
    86                      from: 'node_modules/redoc/bundles/redoc.standalone.js',
    87                      to: 'assets/scripts/redoc.standalone.js'
    88                  },
    89                  {
    90                      from: 'node_modules/monaco-editor/min/vs/base/browser/ui/codicons/codicon',
    91                      to: 'assets/fonts'
    92                  }
    93              ]
    94          }),
    95          new MonacoWebpackPlugin({
    96              // https://github.com/microsoft/monaco-editor-webpack-plugin#options
    97              languages: ['yaml']
    98          }),
    99          codecovWebpackPlugin({
   100              enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
   101              bundleName: "argo-cd-ui",
   102              uploadToken: process.env.CODECOV_TOKEN,
   103          }),
   104      ],
   105      devServer: {
   106          compress: false,
   107          historyApiFallback: {
   108              disableDotRule: true
   109          },
   110          port: 4000,
   111          host: process.env.ARGOCD_E2E_YARN_HOST || 'localhost',
   112          proxy: {
   113              '/extensions': proxyConf,
   114              '/api': proxyConf,
   115              '/auth': proxyConf,
   116              '/terminal': {
   117                target: process.env.ARGOCD_API_URL || 'ws://localhost:8080',
   118                ws: true,
   119              },
   120              '/swagger-ui': proxyConf,
   121              '/swagger.json': proxyConf
   122          }
   123      }
   124  };
   125  
   126  if (isProd) {
   127      config.performance = {
   128          hints: 'error',
   129          // Max size is 6MB before gzip.
   130          maxEntrypointSize: 6 * 1024 * 1024,
   131          maxAssetSize: 6 * 1024 * 1024,
   132      };
   133  }
   134  
   135  if (! isProd) {
   136      config.devtool = 'eval-source-map';
   137  }
   138  
   139  module.exports = config;