blob: a48f7b97668bcb58cfb439e5211a457b8786327c [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 autoprefixer = require('autoprefixer');
12const CopyWebpackPlugin = require("copy-webpack-plugin");
13const TerserPlugin = require('terser-webpack-plugin');
14
15// const __dirname = (path => path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname());
16
17module.exports = (env) => {
18 const distPath = path.resolve(__dirname, env === "release" ? "." : "../..", "dist");
19 const frameworkPath = path.resolve(__dirname, env === "release" ? "../../framework" : "../..", "dist");
20 return [{
21 name: "App",
22
23 mode: "none", //disable default behavior
24
25 target: "web",
26
27 context: path.resolve(__dirname, "src"),
28
29 entry: {
30 helpApp: ["./plugin.tsx"]
31 },
32
33 devtool: env === "release" ? false : "source-map",
34
35 resolve: {
36 extensions: [".ts", ".tsx", ".js", ".jsx"]
37 },
38
39 output: {
40 path: distPath,
41 filename: "[name].js",
42 library: "[name]",
43 libraryTarget: "umd2",
44 chunkFilename: "[name].js"
45 },
46 module: {
47 rules: [{
48 test: /\.tsx?$/,
49 exclude: /node_modules/,
50 use: [{
51 loader: "babel-loader"
52 }, {
53 loader: "ts-loader"
54 }]
55 }, {
56 test: /\.jsx?$/,
57 exclude: /node_modules/,
58 use: [{
59 loader: "babel-loader"
60 }]
61 }, {
62 test: /\.css$/,
63 use: [{
64 loader: 'style-loader'
65 }, {
66 loader: 'css-loader',
67 options: {
68 modules: true,
69 localIdentName: env !== "release" ? '[name]_[local]_[hash:base64:5]' : '[hash]'
70 }
71 }, {
72 loader: 'postcss-loader',
73 options: {
74 plugins: () => [autoprefixer]
75 }
76 }]
sai-neetha15e2d3a2023-03-20 08:05:47 +010077 }, {
78 //don't minify images
79 test: /\.(png|gif|jpg|svg)$/,
80 use: [{
81 loader: 'url-loader',
82 options: {
83 limit: 10,
84 name: './images/[name].[ext]'
85 }
86 }]
herberte6d0d672019-12-14 01:05:47 +010087 }]
88 },
89
90 optimization: {
91 noEmitOnErrors: true,
92 namedModules: env !== "release",
93 minimize: env === "release",
94 minimizer: env !== "release" ? [] : [new TerserPlugin({
95 terserOptions: {
96 warnings: false, // false, true, "verbose"
97 compress: {
98 drop_console: true,
99 drop_debugger: true,
100 }
101 }
102 })],
103 },
104
105 plugins: [
106 new webpack.DllReferencePlugin({
107 context: path.resolve(__dirname, "../../framework/src"),
108 manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")),
109 sourceType: "umd2"
110 }),
111 new webpack.DllReferencePlugin({
112 context: path.resolve(__dirname, "../../framework/src"),
113 manifest: require(path.resolve(frameworkPath, "app-manifest.json")),
114 sourceType: "umd2"
115 }),
Aijana Schumann1a868112022-02-01 13:18:42 +0100116 ...(env === "release" ? [
herberte6d0d672019-12-14 01:05:47 +0100117 new webpack.DefinePlugin({
118 "process.env": {
119 NODE_ENV: "'production'",
120 VERSION: JSON.stringify(require("./package.json").version)
121 }
122 }),
123 ] : [
124 new webpack.DefinePlugin({
125 "process.env": {
126 NODE_ENV: "'development'",
127 VERSION: JSON.stringify(require("./package.json").version)
128 }
129 }),
130 new CopyWebpackPlugin([{
131 from: 'index.html',
132 to: distPath
133 }]),
Aijana Schumann1a868112022-02-01 13:18:42 +0100134 ])
herberte6d0d672019-12-14 01:05:47 +0100135 ],
136 devServer: {
137 public: "http://localhost:3100",
138 contentBase: frameworkPath,
139
140 compress: true,
141 headers: {
142 "Access-Control-Allow-Origin": "*"
143 },
144 host: "0.0.0.0",
145 port: 3100,
146 disableHostCheck: true,
147 historyApiFallback: true,
148 inline: true,
149 hot: false,
150 quiet: false,
151 stats: {
152 colors: true
153 },
154 proxy: {
155 "/oauth2/": {
Michael Dürrea2b6dd32022-09-08 09:45:06 +0200156 //target: "http://10.20.6.29:48181",
157 target: "http://sdnr:8181",
herberte6d0d672019-12-14 01:05:47 +0100158 secure: false
159 },
160 "/database/": {
Michael Dürrea2b6dd32022-09-08 09:45:06 +0200161 //target: "http://10.20.6.29:48181",
162 target: "http://sdnr:8181",
herberte6d0d672019-12-14 01:05:47 +0100163 secure: false
164 },
165 "/restconf/": {
Michael Dürrea2b6dd32022-09-08 09:45:06 +0200166 //target: "http://10.20.6.29:48181",
167 target: "http://sdnr:8181",
168 secure: false
169 },
170 "/rests/": {
171 target: "http://sdnr:8181",
herberte6d0d672019-12-14 01:05:47 +0100172 secure: false
173 },
174 "/help/": {
Michael Dürrea2b6dd32022-09-08 09:45:06 +0200175 //target: "http://10.20.6.29:48181",
176 target: "http://sdnr:8181",
herberte6d0d672019-12-14 01:05:47 +0100177 secure: false
178 },
179 "/websocket/": {
Michael Dürrea2b6dd32022-09-08 09:45:06 +0200180 //target: "http://10.20.6.29:48181",
181 target: "http://sdnr:8181",
herberte6d0d672019-12-14 01:05:47 +0100182 ws: true,
183 changeOrigin: true,
184 secure: false
185 }
186 }
187 }
188 }];
189}