blob: c91b1f4cc3667da1dec6311e3861f39a53a5d915 [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 }]
60 }]
61 },
62 optimization: {
63 noEmitOnErrors: true,
64 namedModules: env !== "release",
65 minimize: env === "release",
66 minimizer: env !== "release" ? [] : [new TerserPlugin({
67 terserOptions: {
68 warnings: false, // false, true, "verbose"
69 compress: {
70 drop_console: true,
71 drop_debugger: true,
72 }
73 }
74 })],
75 },
76 plugins: [
77 new webpack.DllReferencePlugin({
78 context: path.resolve(__dirname, "../../framework/src"),
79 manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")),
80 sourceType: "umd2"
81 }),
82 new webpack.DllReferencePlugin({
83 context: path.resolve(__dirname, "../../framework/src"),
84 manifest: require(path.resolve(frameworkPath, "app-manifest.json")),
85 sourceType: "umd2"
86 }),
87 ...(env === "release") ? [
88 new webpack.DefinePlugin({
89 "process.env": {
90 NODE_ENV: "'production'",
91 VERSION: JSON.stringify(require("./package.json").version)
92 }
93 })
94 ] : [
95 new webpack.DefinePlugin({
96 "process.env": {
97 NODE_ENV: "'development'",
98 VERSION: JSON.stringify(require("./package.json").version)
99 }
100 }),
101 new CopyWebpackPlugin([{
102 from: 'index.html',
103 to: distPath
104 }]),
105 ]
106 ],
107
108 devServer: {
109 public: "http://localhost:3100",
110 contentBase: frameworkPath,
111
112 compress: true,
113 headers: {
114 "Access-Control-Allow-Origin": "*"
115 },
116 host: "0.0.0.0",
117 port: 3100,
118 disableHostCheck: true,
119 historyApiFallback: true,
120 inline: true,
121 hot: false,
122 quiet: false,
123 stats: {
124 colors: true
125 },
126 proxy: {
127 "/oauth2/": {
Aijana Schumannd0fc4322020-02-12 09:08:39 +0100128 target: "http://localhost:48181",
herberte6d0d672019-12-14 01:05:47 +0100129 secure: false
130 },
131 "/database/": {
Aijana Schumannd0fc4322020-02-12 09:08:39 +0100132 target: "http://localhost:48181",
herberte6d0d672019-12-14 01:05:47 +0100133 secure: false
134 },
135 "/restconf/": {
Aijana Schumannd0fc4322020-02-12 09:08:39 +0100136 target: "http://localhost:48181",
herberte6d0d672019-12-14 01:05:47 +0100137 secure: false
138 },
139 "/help/": {
Aijana Schumannd0fc4322020-02-12 09:08:39 +0100140 target: "http://localhost:48181",
herberte6d0d672019-12-14 01:05:47 +0100141 secure: false
142 },
143 "/websocket/": {
Aijana Schumannd0fc4322020-02-12 09:08:39 +0100144 target: "http://localhost:48181",
herberte6d0d672019-12-14 01:05:47 +0100145 ws: true,
146 changeOrigin: true,
147 secure: false
148 }
149 }
150 }
151 }];
152}