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