blob: bc26de1cb549d3847bd0953ba0df96c73e08979a [file] [log] [blame]
herberte6d0d672019-12-14 01:05:47 +01001/**
2 * Webpack 4 configuration file
3 * see https://webpack.js.org/configuration/
4 * see https://webpack.js.org/configuration/dev-server/
5 */
6
7"use strict";
8
9const path = require("path");
10const webpack = require("webpack");
11const CopyWebpackPlugin = require("copy-webpack-plugin");
12const TerserPlugin = require('terser-webpack-plugin');
13
14// const __dirname = (path => path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname());
15
16module.exports = (env) => {
17 const distPath = path.resolve(__dirname, env === "release" ? "." : "../..", "dist");
18 const frameworkPath = path.resolve(__dirname, env === "release" ? "../../framework" : "../..", "dist");
19 return [{
20 name: "App",
21
22 mode: "none", //disable default behavior
23
24 target: "web",
25
26 context: path.resolve(__dirname, "src"),
27
28 entry: {
29 faultApp: ["./pluginFault.tsx"]
30 },
31
32 devtool: env === "release" ? false : "source-map",
33
34 resolve: {
35 extensions: [".ts", ".tsx", ".js", ".jsx"]
36 },
37
38 output: {
39 path: distPath,
40 filename: "[name].js",
41 library: "[name]",
42 libraryTarget: "umd2",
43 chunkFilename: "[name].js"
44 },
45 module: {
46 rules: [{
47 test: /\.tsx?$/,
48 exclude: /node_modules/,
49 use: [{
50 loader: "babel-loader"
51 }, {
52 loader: "ts-loader"
53 }]
54 }, {
55 test: /\.jsx?$/,
56 exclude: /node_modules/,
57 use: [{
58 loader: "babel-loader"
59 }]
sai-neetha15e2d3a2023-03-20 08:05:47 +010060 },{
61 //don't minify images
62 test: /\.(png|gif|jpg|svg)$/,
63 use: [{
64 loader: 'url-loader',
65 options: {
66 limit: 10,
67 name: './images/[name].[ext]'
68 }
69 }]
herberte6d0d672019-12-14 01:05:47 +010070 }]
71 },
72 optimization: {
73 noEmitOnErrors: true,
74 namedModules: env !== "release",
75 minimize: env === "release",
76 minimizer: env !== "release" ? [] : [new TerserPlugin({
77 terserOptions: {
78 warnings: false, // false, true, "verbose"
79 compress: {
80 drop_console: true,
81 drop_debugger: true,
82 }
83 }
84 })],
85 },
86 plugins: [
87 new webpack.DllReferencePlugin({
88 context: path.resolve(__dirname, "../../framework/src"),
89 manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")),
90 sourceType: "umd2"
91 }),
92 new webpack.DllReferencePlugin({
93 context: path.resolve(__dirname, "../../framework/src"),
94 manifest: require(path.resolve(frameworkPath, "app-manifest.json")),
95 sourceType: "umd2"
96 }),
Aijana Schumann1a868112022-02-01 13:18:42 +010097 ...(env === "release" ? [
herberte6d0d672019-12-14 01:05:47 +010098 new webpack.DefinePlugin({
99 "process.env": {
100 NODE_ENV: "'production'",
101 VERSION: JSON.stringify(require("./package.json").version)
102 }
103 })
104 ] : [
105 new webpack.DefinePlugin({
106 "process.env": {
107 NODE_ENV: "'development'",
108 VERSION: JSON.stringify(require("./package.json").version)
109 }
110 }),
111 new CopyWebpackPlugin([{
112 from: 'index.html',
113 to: distPath
114 }]),
Aijana Schumann1a868112022-02-01 13:18:42 +0100115 ])
herberte6d0d672019-12-14 01:05:47 +0100116 ],
117
118 devServer: {
119 public: "http://localhost:3100",
120 contentBase: frameworkPath,
121
122 compress: true,
123 headers: {
124 "Access-Control-Allow-Origin": "*"
125 },
126 host: "0.0.0.0",
127 port: 3100,
128 disableHostCheck: true,
129 historyApiFallback: true,
130 inline: true,
131 hot: false,
132 quiet: false,
133 stats: {
134 colors: true
135 },
Aijana Schumann3d022712020-08-12 12:28:06 +0200136 proxy: {
herberte6d0d672019-12-14 01:05:47 +0100137 "/oauth2/": {
sai-neetha15e2d3a2023-03-20 08:05:47 +0100138 target: "http://sdnc-web:8080",
herberte6d0d672019-12-14 01:05:47 +0100139 secure: false
140 },
141 "/database/": {
sai-neetha15e2d3a2023-03-20 08:05:47 +0100142 target: "http://sdnc-web:8080",
herberte6d0d672019-12-14 01:05:47 +0100143 secure: false
144 },
145 "/restconf/": {
sai-neetha15e2d3a2023-03-20 08:05:47 +0100146 target: "http://sdnc-web:8080",
Aijana Schumann3d022712020-08-12 12:28:06 +0200147 secure: false
148 },
149 "/rests/": {
sai-neetha15e2d3a2023-03-20 08:05:47 +0100150 target: "http://sdnc-web:8080",
herberte6d0d672019-12-14 01:05:47 +0100151 secure: false
152 },
153 "/help/": {
sai-neetha15e2d3a2023-03-20 08:05:47 +0100154 target: "http://sdnc-web:8080",
herberte6d0d672019-12-14 01:05:47 +0100155 secure: false
156 },
Aijana Schumann3d022712020-08-12 12:28:06 +0200157 "/websocket": {
sai-neetha15e2d3a2023-03-20 08:05:47 +0100158 target: "http://sdnc-web:8080",
herberte6d0d672019-12-14 01:05:47 +0100159 ws: true,
160 changeOrigin: true,
161 secure: false
162 }
163 }
164 }
165 }];
166}