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: [
|
| 46 | "./app.tsx",
|
| 47 | "./services",
|
Michael Dürre | 7dbe38b | 2020-07-16 05:55:07 +0200 | [diff] [blame] | 48 | "./components/objectDump",
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 49 | "./components/material-table",
|
| 50 | "./components/material-ui",
|
| 51 | "./utilities/elasticSearch",
|
| 52 | "./models"],
|
| 53 | },
|
| 54 |
|
| 55 | devtool: env === "release" ? false : "source-map",
|
| 56 |
|
| 57 | resolve: {
|
| 58 | extensions: [".ts", ".tsx", ".js", ".jsx"]
|
| 59 | },
|
| 60 |
|
| 61 | output: {
|
| 62 | path: distPath,
|
| 63 | library: "[name]", // related to webpack.DllPlugin::name
|
| 64 | libraryTarget: "umd2",
|
| 65 | filename: "[name].js",
|
| 66 | chunkFilename: "[name].js"
|
| 67 | },
|
| 68 |
|
| 69 | module: {
|
| 70 | rules: [{
|
| 71 | test: /\.tsx?$/,
|
| 72 | exclude: /node_modules/,
|
| 73 | use: [{
|
| 74 | loader: "babel-loader"
|
| 75 | }, {
|
| 76 | loader: "ts-loader"
|
| 77 | }]
|
| 78 | }, {
|
| 79 | test: /\.jsx?$/,
|
| 80 | exclude: /node_modules/,
|
| 81 | use: [{
|
| 82 | loader: "babel-loader"
|
| 83 | }]
|
| 84 | }, {
|
| 85 | test: /\.(png|gif|jpg|svg)$/,
|
| 86 | use: [{
|
| 87 | loader: 'url-loader',
|
| 88 | options: {
|
| 89 | limit: 10000,
|
| 90 | name: './images/[hash].[ext]'
|
| 91 | }
|
| 92 | }]
|
| 93 | }]
|
| 94 | },
|
| 95 |
|
| 96 | optimization: {
|
| 97 | noEmitOnErrors: true,
|
| 98 | namedModules: env !== "release",
|
| 99 | minimize: env === "release",
|
| 100 | minimizer: env !== "release" ? [] : [new TerserPlugin({
|
| 101 | terserOptions: {
|
| 102 | mangle: {
|
| 103 | reserved: ["./app.tsx"]
|
| 104 | },
|
| 105 | warnings: false, // false, true, "verbose"
|
| 106 | compress: {
|
| 107 | drop_console: true,
|
| 108 | drop_debugger: true,
|
| 109 | }
|
| 110 | }
|
| 111 | })],
|
| 112 | },
|
| 113 |
|
| 114 | plugins: [
|
| 115 | new CopyWebpackPlugin([{
|
| 116 | from: '../../node_modules/requirejs/require.js',
|
| 117 | to: '.'
|
| 118 | }, {
|
| 119 | from: './favicon.ico',
|
| 120 | to: '.'
|
| 121 | }, {
|
| 122 | from: env === "release" ? './index.html' : 'index.dev.html',
|
| 123 | to: './index.html'
|
| 124 | }]),
|
| 125 | new requirejsPlugin({
|
| 126 | path: distPath,
|
| 127 | filename: 'config.js',
|
| 128 | baseUrl: '',
|
| 129 | pathUrl: '',
|
| 130 | processOutput: function (assets) {
|
Michael Dürre | 7dbe38b | 2020-07-16 05:55:07 +0200 | [diff] [blame] | 131 | let mainConfig = JSON.stringify(assets, null, 2);
|
| 132 | mainConfig = mainConfig.slice(0,-1); // remove closing bracket from string
|
| 133 | const entireConfig = mainConfig.concat(", waitSeconds: 30}"); // add waitSeconds to config
|
| 134 | return 'require.config(' + entireConfig + ')';
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 135 | }
|
| 136 | }),
|
| 137 | // new HtmlWebpackPlugin({
|
| 138 | // filename: "index.html",
|
| 139 | // template: "./index.html",
|
| 140 | // inject: "head"
|
| 141 | // }),
|
| 142 | // new HtmlWebpackIncludeAssetsPlugin({
|
| 143 | // assets: ['vendor.js'],
|
| 144 | // append: false
|
| 145 | // }),
|
| 146 | new webpack.DllReferencePlugin({
|
| 147 | context: path.resolve(__dirname, "src"),
|
| 148 | manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")),
|
| 149 | sourceType: "umd2"
|
| 150 | }),
|
| 151 | new webpack.DllPlugin({
|
| 152 | context: path.resolve(__dirname, "src"),
|
| 153 | name: "[name]",
|
| 154 | path: path.resolve(distPath, "[name]-manifest.json")
|
| 155 | }),
|
| 156 | ...(env === "release") ? [
|
| 157 | new webpack.DefinePlugin({
|
| 158 | "process.env": {
|
| 159 | NODE_ENV: "'production'",
|
| 160 | VERSION: JSON.stringify(require("./package.json").version)
|
| 161 | }
|
| 162 | }),
|
| 163 | ] : [
|
| 164 | new webpack.HotModuleReplacementPlugin(),
|
| 165 | new webpack.DefinePlugin({
|
| 166 | "process.env": {
|
| 167 | NODE_ENV: "'development'",
|
| 168 | VERSION: JSON.stringify(require("./package.json").version)
|
| 169 | }
|
| 170 | }),
|
| 171 | new webpack.WatchIgnorePlugin([
|
| 172 | /css\.d\.ts$/,
|
| 173 | /less\.d\.ts$/
|
Aijana Schumann | 4bd84be | 2020-08-27 09:01:53 +0200 | [diff] [blame] | 174 | ]),
|
| 175 | new CopyWebpackPlugin([{
|
| 176 | from: './assets/version.json',
|
| 177 | to: './version.json'
|
| 178 | }])
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 179 | ]
|
| 180 | ],
|
| 181 |
|
| 182 | devServer: {
|
Aijana Schumann | 3d02271 | 2020-08-12 12:28:06 +0200 | [diff] [blame] | 183 | public: "http://10.20.6.29:3100",
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 184 | contentBase: distPath,
|
| 185 |
|
| 186 | compress: true,
|
| 187 | headers: {
|
| 188 | "Access-Control-Allow-Origin": "*"
|
| 189 | },
|
| 190 | host: "0.0.0.0",
|
| 191 | port: 3100,
|
| 192 | disableHostCheck: true,
|
| 193 | historyApiFallback: true,
|
| 194 | inline: true,
|
| 195 | hot: false,
|
| 196 | quiet: false,
|
| 197 | stats: {
|
| 198 | colors: true
|
| 199 | },
|
| 200 | proxy: {
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 201 | "/oauth2/": {
|
Aijana Schumann | 3d02271 | 2020-08-12 12:28:06 +0200 | [diff] [blame] | 202 | target: "http://10.20.6.29:48181",
|
herbert | 05ef023 | 2020-02-01 16:00:00 +0100 | [diff] [blame] | 203 | secure: false
|
| 204 | },
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 205 | "/database/": {
|
Aijana Schumann | 3d02271 | 2020-08-12 12:28:06 +0200 | [diff] [blame] | 206 | target: "http://10.20.6.29:48181",
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 207 | secure: false
|
| 208 | },
|
| 209 | "/restconf/": {
|
Aijana Schumann | 3d02271 | 2020-08-12 12:28:06 +0200 | [diff] [blame] | 210 | target: "http://10.20.6.29:48181",
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 211 | secure: false
|
| 212 | },
|
| 213 | "/help/": {
|
Aijana Schumann | 3d02271 | 2020-08-12 12:28:06 +0200 | [diff] [blame] | 214 | target: "http://10.20.6.29:48181",
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 215 | secure: false
|
| 216 | },
|
Aijana Schumann | 4bd84be | 2020-08-27 09:01:53 +0200 | [diff] [blame] | 217 | "/about": {
|
| 218 | target: "http://10.20.6.29:48181",
|
| 219 | secure: false
|
| 220 | },
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 221 | "/websocket": {
|
Aijana Schumann | 3d02271 | 2020-08-12 12:28:06 +0200 | [diff] [blame] | 222 | target: "http://10.20.6.29:48181",
|
Aijana Schumann | d0fc432 | 2020-02-12 09:08:39 +0100 | [diff] [blame] | 223 | ws: true,
|
| 224 | changeOrigin: true,
|
herbert | e6d0d67 | 2019-12-14 01:05:47 +0100 | [diff] [blame] | 225 | secure: false
|
| 226 | }
|
| 227 | }
|
| 228 | }
|
| 229 |
|
| 230 | }];
|
| 231 | }
|
| 232 |
|
| 233 |
|