herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 1 | /**
|
| 2 | * ============LICENSE_START========================================================================
|
| 3 | * ONAP : ccsdk feature sdnr wt odlux
|
| 4 | * =================================================================================================
|
| 5 | * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
|
| 6 | * =================================================================================================
|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
| 8 | * in compliance with the License. You may obtain a copy of the License at
|
| 9 | *
|
| 10 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 11 | *
|
| 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License
|
| 13 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
| 14 | * or implied. See the License for the specific language governing permissions and limitations under
|
| 15 | * the License.
|
| 16 | * ============LICENSE_END==========================================================================
|
| 17 | */
|
| 18 | /**
|
| 19 | * Webpack 4 configuration file
|
| 20 | * see https://webpack.js.org/configuration/
|
| 21 | * see https://webpack.js.org/configuration/dev-server/
|
| 22 | */
|
| 23 |
|
| 24 | "use strict";
|
| 25 |
|
| 26 | const path = require("path");
|
| 27 | const webpack = require("webpack");
|
| 28 | const CopyWebpackPlugin = require("copy-webpack-plugin");
|
| 29 | const requirejsPlugin = require('requirejs-webpack-plugin');
|
| 30 | const TerserPlugin = require('terser-webpack-plugin');
|
| 31 |
|
| 32 | // const __dirname = (path => path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname());
|
| 33 |
|
| 34 | module.exports = (env) => {
|
| 35 | const distPath = path.resolve(__dirname, env === "release" ? "." : "..", "dist");
|
| 36 | const frameworkPath = path.resolve(__dirname, env === "release" ? "." : "..", "dist");
|
| 37 | return [{
|
| 38 | name: "Client",
|
| 39 | mode: "none", //disable default behavior
|
| 40 | target: "web",
|
| 41 |
|
| 42 | context: path.resolve(__dirname, "src"),
|
| 43 |
|
| 44 | entry: {
|
| 45 | app: [
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 46 | "./run.ts",
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 47 | "./app.tsx",
|
| 48 | "./services",
|
Michael Dürre | 7dbe38b | 2020-07-16 05:55:07 +0200 | [diff] [blame] | 49 | "./components/objectDump",
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 50 | "./components/material-table",
|
| 51 | "./components/material-ui",
|
| 52 | "./utilities/elasticSearch",
|
| 53 | "./models"],
|
| 54 | },
|
| 55 |
|
| 56 | devtool: env === "release" ? false : "source-map",
|
| 57 |
|
| 58 | resolve: {
|
| 59 | extensions: [".ts", ".tsx", ".js", ".jsx"]
|
| 60 | },
|
| 61 |
|
| 62 | output: {
|
| 63 | path: distPath,
|
| 64 | library: "[name]", // related to webpack.DllPlugin::name
|
| 65 | libraryTarget: "umd2",
|
| 66 | filename: "[name].js",
|
| 67 | chunkFilename: "[name].js"
|
| 68 | },
|
| 69 |
|
| 70 | module: {
|
| 71 | rules: [{
|
| 72 | test: /\.tsx?$/,
|
| 73 | exclude: /node_modules/,
|
| 74 | use: [{
|
| 75 | loader: "babel-loader"
|
| 76 | }, {
|
| 77 | loader: "ts-loader"
|
| 78 | }]
|
| 79 | }, {
|
| 80 | test: /\.jsx?$/,
|
| 81 | exclude: /node_modules/,
|
| 82 | use: [{
|
| 83 | loader: "babel-loader"
|
| 84 | }]
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 85 | },
|
| 86 | {
|
Michael DÜrre | 0eaf2d5 | 2021-09-23 10:03:55 +0200 | [diff] [blame] | 87 | //don't minify images
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 88 | test: /\.(png|gif|jpg|svg)$/,
|
| 89 | use: [{
|
| 90 | loader: 'url-loader',
|
| 91 | options: {
|
Michael DÜrre | 0eaf2d5 | 2021-09-23 10:03:55 +0200 | [diff] [blame] | 92 | limit: 10,
|
| 93 | name: './images/[name].[ext]'
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 94 | }
|
| 95 | }]
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 96 | }
|
| 97 | ]
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 98 | },
|
| 99 |
|
| 100 | optimization: {
|
| 101 | noEmitOnErrors: true,
|
| 102 | namedModules: env !== "release",
|
| 103 | minimize: env === "release",
|
| 104 | minimizer: env !== "release" ? [] : [new TerserPlugin({
|
| 105 | terserOptions: {
|
| 106 | mangle: {
|
| 107 | reserved: ["./app.tsx"]
|
| 108 | },
|
| 109 | warnings: false, // false, true, "verbose"
|
| 110 | compress: {
|
| 111 | drop_console: true,
|
| 112 | drop_debugger: true,
|
| 113 | }
|
| 114 | }
|
| 115 | })],
|
| 116 | },
|
| 117 |
|
| 118 | plugins: [
|
| 119 | new CopyWebpackPlugin([{
|
| 120 | from: '../../node_modules/requirejs/require.js',
|
| 121 | to: '.'
|
| 122 | }, {
|
| 123 | from: './favicon.ico',
|
| 124 | to: '.'
|
| 125 | }, {
|
| 126 | from: env === "release" ? './index.html' : 'index.dev.html',
|
| 127 | to: './index.html'
|
| 128 | }]),
|
| 129 | new requirejsPlugin({
|
| 130 | path: distPath,
|
| 131 | filename: 'config.js',
|
| 132 | baseUrl: '',
|
| 133 | pathUrl: '',
|
| 134 | processOutput: function (assets) {
|
Michael Dürre | 7dbe38b | 2020-07-16 05:55:07 +0200 | [diff] [blame] | 135 | let mainConfig = JSON.stringify(assets, null, 2);
|
| 136 | mainConfig = mainConfig.slice(0,-1); // remove closing bracket from string
|
| 137 | const entireConfig = mainConfig.concat(", waitSeconds: 30}"); // add waitSeconds to config
|
| 138 | return 'require.config(' + entireConfig + ')';
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 139 | }
|
| 140 | }),
|
| 141 | // new HtmlWebpackPlugin({
|
| 142 | // filename: "index.html",
|
| 143 | // template: "./index.html",
|
| 144 | // inject: "head"
|
| 145 | // }),
|
| 146 | // new HtmlWebpackIncludeAssetsPlugin({
|
| 147 | // assets: ['vendor.js'],
|
| 148 | // append: false
|
| 149 | // }),
|
| 150 | new webpack.DllReferencePlugin({
|
| 151 | context: path.resolve(__dirname, "src"),
|
| 152 | manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")),
|
| 153 | sourceType: "umd2"
|
| 154 | }),
|
| 155 | new webpack.DllPlugin({
|
| 156 | context: path.resolve(__dirname, "src"),
|
| 157 | name: "[name]",
|
| 158 | path: path.resolve(distPath, "[name]-manifest.json")
|
| 159 | }),
|
| 160 | ...(env === "release") ? [
|
| 161 | new webpack.DefinePlugin({
|
| 162 | "process.env": {
|
| 163 | NODE_ENV: "'production'",
|
| 164 | VERSION: JSON.stringify(require("./package.json").version)
|
| 165 | }
|
| 166 | }),
|
| 167 | ] : [
|
| 168 | new webpack.HotModuleReplacementPlugin(),
|
| 169 | new webpack.DefinePlugin({
|
| 170 | "process.env": {
|
| 171 | NODE_ENV: "'development'",
|
| 172 | VERSION: JSON.stringify(require("./package.json").version)
|
| 173 | }
|
| 174 | }),
|
| 175 | new webpack.WatchIgnorePlugin([
|
| 176 | /css\.d\.ts$/,
|
| 177 | /less\.d\.ts$/
|
Aijana Schumann | 4bd84be | 2020-08-27 09:01:53 +0200 | [diff] [blame] | 178 | ]),
|
| 179 | new CopyWebpackPlugin([{
|
| 180 | from: './assets/version.json',
|
| 181 | to: './version.json'
|
| 182 | }])
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 183 | ]
|
| 184 | ],
|
| 185 |
|
| 186 | devServer: {
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 187 | public: "http://localhost:3100",
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 188 | contentBase: distPath,
|
| 189 |
|
| 190 | compress: true,
|
| 191 | headers: {
|
| 192 | "Access-Control-Allow-Origin": "*"
|
| 193 | },
|
| 194 | host: "0.0.0.0",
|
| 195 | port: 3100,
|
| 196 | disableHostCheck: true,
|
| 197 | historyApiFallback: true,
|
| 198 | inline: true,
|
| 199 | hot: false,
|
| 200 | quiet: false,
|
| 201 | stats: {
|
| 202 | colors: true
|
| 203 | },
|
| 204 | proxy: {
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 205 | "/about": {
|
| 206 | // target: "http://10.20.6.29:48181",
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 207 | target: "http://sdnr:8181",
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 208 | secure: false
|
| 209 | },
|
| 210 | "/yang-schema/": {
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 211 | target: "http://sdnr:8181",
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 212 | secure: false
|
| 213 | },
|
| 214 | "/oauth/": {
|
| 215 | // target: "https://10.20.35.188:30205",
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 216 | target: "http://sdnr:8181",
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 217 | secure: false
|
| 218 | },
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 219 | "/oauth2/": {
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 220 | // target: "https://10.20.35.188:30205",
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 221 | target: "http://sdnr:8181",
|
herbert | 05ef023 | 2020-02-01 16:00:00 +0100 | [diff] [blame] | 222 | secure: false
|
| 223 | },
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 224 | "/database/": {
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 225 | target: "http://sdnr:8181",
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 226 | secure: false
|
| 227 | },
|
| 228 | "/restconf/": {
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 229 | target: "http://sdnr:8181",
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 230 | secure: false
|
| 231 | },
|
| 232 | "/rests/": {
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 233 | target: "http://sdnr:8181",
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 234 | secure: false
|
| 235 | },
|
| 236 | "/help/": {
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 237 | target: "http://sdnr:8181",
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 238 | secure: false
|
| 239 | },
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 240 | "/about/": {
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 241 | target: "http://sdnr:8181",
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 242 | secure: false
|
| 243 | },
|
| 244 | "/tree/": {
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 245 | target: "http://sdnr:8181",
|
Aijana Schumann | 4bd84be | 2020-08-27 09:01:53 +0200 | [diff] [blame] | 246 | secure: false
|
| 247 | },
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 248 | "/websocket": {
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 249 | target: "http://sdnr:8181",
|
Aijana Schumann | 8515052 | 2021-02-15 18:22:28 +0100 | [diff] [blame] | 250 | ws: true,
|
| 251 | changeOrigin: true,
|
| 252 | secure: false
|
| 253 | },
|
| 254 | "/apidoc": {
|
Aijana Schumann | 152cb38 | 2021-12-06 15:09:15 +0100 | [diff] [blame] | 255 | target: "http://sdnr:8181",
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 256 | ws: true,
|
| 257 | changeOrigin: true,
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 258 | secure: false
|
| 259 | }
|
| 260 | }
|
| 261 | }
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 262 | }];
|
| 263 | }
|
| 264 |
|
| 265 |
|