summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/framework/webpack.config.js
blob: b5d31c262c74b0ecaa8bfdff7294679793662ac7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/**
 * ============LICENSE_START========================================================================
 * ONAP : ccsdk feature sdnr wt odlux
 * =================================================================================================
 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
 * =================================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 * ============LICENSE_END==========================================================================
 */
/**
 * Webpack 4 configuration file
 * see https://webpack.js.org/configuration/
 * see https://webpack.js.org/configuration/dev-server/
 */

"use strict";

const path = require("path");
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const requirejsPlugin = require('requirejs-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');

// const __dirname = (path => path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname());

module.exports = (env) => {
  const distPath = path.resolve(__dirname, env === "release" ? "." : "..", "dist");
  const frameworkPath = path.resolve(__dirname, env === "release" ? "." : "..", "dist");
  return [{
    name: "Client",
    mode: "none", //disable default behavior
    target: "web",

    context: path.resolve(__dirname, "src"),

    entry: {
      app: [
        "./run.ts",
        "./app.tsx",
        "./services",
        "./components/objectDump",
        "./components/material-table",
        "./components/material-ui",
        "./utilities/elasticSearch",
        "./models"],
    },

    devtool: env === "release" ? false : "source-map",

    resolve: {
      extensions: [".ts", ".tsx", ".js", ".jsx"]
    },

    output: {
      path: distPath,
      library: "[name]", // related to webpack.DllPlugin::name
      libraryTarget: "umd2",
      filename: "[name].js",
      chunkFilename: "[name].js"
    },

    module: {
      rules: [{
        test: /\.tsx?$/,
        exclude: /node_modules/,
        use: [{
          loader: "babel-loader"
        }, {
          loader: "ts-loader"
        }]
      }, {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        use: [{
          loader: "babel-loader"
        }]
      }, {
        test: /\.(png|gif|jpg|svg)$/,
        use: [{
          loader: 'url-loader',
          options: {
            limit: 10000,
            name: './images/[hash].[ext]'
          }
        }]
      }]
    },

    optimization: {
      noEmitOnErrors: true,
      namedModules: env !== "release",
      minimize: env === "release",
      minimizer: env !== "release" ? [] : [new TerserPlugin({
        terserOptions: {
          mangle: {
            reserved: ["./app.tsx"]
          },
          warnings: false, // false, true, "verbose"
          compress: {
            drop_console: true,
            drop_debugger: true,
          }
        }
      })],
    },

    plugins: [
      new CopyWebpackPlugin([{
        from: '../../node_modules/requirejs/require.js',
        to: '.'
      }, {
        from: './favicon.ico',
        to: '.'
      }, {
        from: env === "release" ? './index.html' : 'index.dev.html',
        to: './index.html'
      }]),
      new requirejsPlugin({
        path: distPath,
        filename: 'config.js',
        baseUrl: '',
        pathUrl: '',
        processOutput: function (assets) {
          let mainConfig =  JSON.stringify(assets, null, 2);
          mainConfig = mainConfig.slice(0,-1); // remove closing bracket from string
          const entireConfig = mainConfig.concat(", waitSeconds: 30}"); // add waitSeconds to config
          return 'require.config(' + entireConfig + ')';
        }
      }),
      // new HtmlWebpackPlugin({
      //   filename: "index.html",
      //   template: "./index.html",
      //   inject: "head"
      // }),
      // new HtmlWebpackIncludeAssetsPlugin({
      //    assets: ['vendor.js'],
      //    append: false
      // }),
      new webpack.DllReferencePlugin({
        context: path.resolve(__dirname, "src"),
        manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")),
        sourceType: "umd2"
      }),
      new webpack.DllPlugin({
        context: path.resolve(__dirname, "src"),
        name: "[name]",
        path: path.resolve(distPath, "[name]-manifest.json")
      }),
      ...(env === "release") ? [
        new webpack.DefinePlugin({
          "process.env": {
            NODE_ENV: "'production'",
            VERSION: JSON.stringify(require("./package.json").version)
          }
        }),
      ] : [
          new webpack.HotModuleReplacementPlugin(),
          new webpack.DefinePlugin({
            "process.env": {
              NODE_ENV: "'development'",
              VERSION: JSON.stringify(require("./package.json").version)
            }
          }),
          new webpack.WatchIgnorePlugin([
            /css\.d\.ts$/,
            /less\.d\.ts$/
          ]),
          new CopyWebpackPlugin([{
            from: './assets/version.json',
            to: './version.json'
          }])
        ]
    ],

    devServer: {
      public: "http://localhost:3100",
      contentBase: distPath,

      compress: true,
      headers: {
        "Access-Control-Allow-Origin": "*"
      },
      host: "0.0.0.0",
      port: 3100,
      disableHostCheck: true,
      historyApiFallback: true,
      inline: true,
      hot: false,
      quiet: false,
      stats: {
        colors: true
      },
      proxy: {
        "/about": {
          // target: "http://10.20.6.29:48181",
          target: "http://localhost:18181",
          secure: false
        }, 
        "/yang-schema/": {
          target: "http://localhost:18181",
          secure: false
        },   
        "/oauth/": {
          // target: "https://10.20.35.188:30205",
          target: "http://localhost:18181",
          secure: false
        },
        "/oauth2/": {
          // target: "https://10.20.35.188:30205",
          target: "http://localhost:18181",
          secure: false
        },
        "/database/": {
          target: "http://localhost:18181",
          secure: false
        },
        "/restconf/": {
          target: "http://localhost:18181",
          secure: false
        },
        "/rests/": {
          target: "http://localhost:18181",
          secure: false
        },
        "/help/": {
          target: "http://localhost:18181",
          secure: false
        },
         "/about/": {
          target: "http://localhost:18181",
          secure: false
        },
        "/tree/": {
          target: "http://localhost:18181",
          secure: false
        },
        "/websocket": {
          target: "http://localhost:18181",
          ws: true,
          changeOrigin: true,
          secure: false
        },
        "/apidoc": {
          target: "http://localhost:18181",
          ws: true,
          changeOrigin: true,
          secure: false
        }
      }
    }
  }];
}
ile.id>176c31dfe190a</staging.profile.id> <!--maven--> <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format> <!--docker tags--> <docker.tag>${project.version}-${maven.build.timestamp}</docker.tag> <!--togglz version--> <togglz.version>2.4.1.Final</togglz.version> <joda.time.version>2.9.9</joda.time.version> <!--sdc-security-utils--> <security.util.lib.version>1.6.0</security.util.lib.version> <!--jacoco--> <jacoco.version>0.8.5</jacoco.version> <java.driver.core.version>4.5.1</java.driver.core.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> <dependency> <groupId>org.glassfish.jersey.ext</groupId> <artifactId>jersey-bean-validation</artifactId> <version>${jersey-bom.version}</version> </dependency> <dependency> <groupId>org.glassfish.hk2.external</groupId> <artifactId>asm-all-repackaged</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <version>${assertj.version}</version> </dependency> <dependency> <groupId>org.jmockit</groupId> <artifactId>jmockit</artifactId> <version>${jmockit.version}</version> </dependency> <dependency> <groupId>com.github.tomakehurst</groupId> <artifactId>wiremock-standalone</artifactId> <version>${wire-mock.version}</version> </dependency> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>${cucumber.version}</version> </dependency> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-junit</artifactId> <version>${cucumber.version}</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>${lang3.version}</version> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy</artifactId> <version>2.4.13</version> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>${netty.version}</version> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-handler</artifactId> <version>${netty.version}</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <!-- must be on the classpath --> <groupId>org.jacoco</groupId> <artifactId>org.jacoco.agent</artifactId> <classifier>runtime</classifier> <version>${jacoco.version}</version> <scope>test</scope> </dependency> <!--JUnit Jupiter Engine to depend on the JUnit5 engine and JUnit 5 API --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>${junitJupiter.version}</version> <scope>test</scope> </dependency> <!--JUnit Jupiter Engine to depend on the JUnit4 engine and JUnit 4 API --> <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> <version>${junitJupiter.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>${mockito.version}</version> <scope>test</scope> </dependency> </dependencies> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.0.1</version> <configuration> <failOnError>false</failOnError> <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet> <docletArtifact> <groupId>org.umlgraph</groupId> <artifactId>umlgraph</artifactId> <version>5.6</version> </docletArtifact> <useStandardDocletOptions>true</useStandardDocletOptions> </configuration> </plugin> </plugins> </reporting> <build> <pluginManagement> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.1.0</version> <configuration> <tarLongFileMode>posix</tarLongFileMode> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.6.0</version> </plugin> <plugin> <groupId>org.sonarsource.scanner.maven</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>3.7.0.1746</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <plugin> <groupId>ru.yaal.maven</groupId> <artifactId>write-text-files-maven-plugin</artifactId> <version>1.1</version> </plugin> <plugin> <groupId>org.codehaus.gmaven</groupId> <artifactId>gmaven-plugin</artifactId> <version>1.5</version> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>3.0.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.1.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.1.0</version> </plugin> <plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.26.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.2.2</version> </plugin> <plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>1.8.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${maven-surefire-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>${maven-surefire-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <groupId>com.github.sylvainlaurent.maven</groupId> <artifactId>yaml-json-validator-maven-plugin</artifactId> <version>1.0.2</version> </plugin> <plugin> <groupId>pl.project13.maven</groupId> <artifactId>git-commit-id-plugin</artifactId> <version>4.0.0</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.17</version> <configuration> <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation> <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression> <skip>${checkstyle.skip}</skip> </configuration> </plugin> <!-- plugin for parsing the project version --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <executions> <execution> <id>parse-version</id> <phase>pre-clean</phase> <goals> <goal>parse-version</goal> </goals> </execution> </executions> </plugin> <!-- Java Code Coverage --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <inherited>false</inherited> <executions> <execution> <id>default-instrument</id> <goals> <goal>instrument</goal> </goals> </execution> <execution> <id>default-restore-instrumented-classes</id> <goals> <goal>restore-instrumented-classes</goal> </goals> </execution> <execution> <id>default-report</id> <goals> <goal>report</goal> </goals> <configuration> <dataFile>${project.build.directory}/jacoco.exec</dataFile> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>3.7.1</version> <dependencies> <dependency> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-webdav-jackrabbit</artifactId> <version>3.0.0</version> </dependency> </dependencies> </plugin> <!-- Set the deployment repositories properties. --> <plugin> <groupId>org.codehaus.gmaven</groupId> <artifactId>gmaven-plugin</artifactId> <executions> <execution> <inherited>false</inherited> <phase>integration-test</phase> <goals> <goal>execute</goal> </goals> <configuration> <source> pom.properties['deploy.url'] = pom.version.contains('-SNAPSHOT') ? project.distributionManagement.snapshotRepository.url : project.distributionManagement.repository.url; pom.properties['repo.id'] = pom.version.contains('-SNAPSHOT') ? project.distributionManagement.snapshotRepository.id : project.distributionManagement.repository.id; </source> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit-platform</artifactId> <version>${maven-surefire-plugin.version}</version> </dependency> </dependencies> <configuration> <printSummary>false</printSummary> <systemPropertyVariables> <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile> </systemPropertyVariables> </configuration> </plugin> <plugin> <groupId>pl.project13.maven</groupId> <artifactId>git-commit-id-plugin</artifactId> <executions> <execution> <goals> <goal>revision</goal> </goals> </execution> </executions> <configuration> <generateGitPropertiesFile>true</generateGitPropertiesFile> <generateGitPropertiesFilename>${project.build.outputDirectory}/META-INF/git.properties </generateGitPropertiesFilename> <failOnNoGitDirectory>true</failOnNoGitDirectory> <verbose>false</verbose> <includeOnlyProperties> <includeOnlyProperty>git.build.version</includeOnlyProperty> <includeOnlyProperty>git.build.time</includeOnlyProperty> <includeOnlyProperty>git.commit.id</includeOnlyProperty> <includeOnlyProperty>git.commit.time</includeOnlyProperty> <includeOnlyProperty>git.commit.user.name</includeOnlyProperty> <includeOnlyProperty>git.commit.user.email</includeOnlyProperty> <includeOnlyProperty>git.commit.message.short</includeOnlyProperty> <includeOnlyProperty>git.commit.message.full</includeOnlyProperty> </includeOnlyProperties> <gitDescribe> <skip>true</skip> </gitDescribe> <useNativeGit>false</useNativeGit> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>all</id> <activation> <activeByDefault>true</activeByDefault> </activation> <modules> <module>onboarding</module> <module>common-app-logging</module> <module>common-app-api</module> <module>common-be</module> <module>catalog-dao</module> <module>catalog-model</module> <module>catalog-be</module> <module>asdctool</module> <module>catalog-ui</module> <module>catalog-fe</module> <module>test-apis-ci</module> <module>ui-ci</module> <module>sdc-os-chef</module> <module>utils/webseal-simulator</module> </modules> </profile> <profile> <id>catalog</id> <activation> <activeByDefault>false</activeByDefault> </activation> <modules> <module>common-app-logging</module> <module>common-app-api</module> <module>common-be</module> <module>catalog-dao</module> <module>catalog-model</module> <module>catalog-be</module> <module>asdctool</module> <module>catalog-ui</module> <module>catalog-fe</module> <module>test-apis-ci</module> <module>ui-ci</module> </modules> </profile> <profile> <id>catalog-be</id> <activation> <activeByDefault>false</activeByDefault> </activation> <modules> <module>common-app-logging</module> <module>common-app-api</module> <module>common-be</module> <module>catalog-dao</module> <module>catalog-model</module> <module>catalog-be</module> </modules> </profile> <profile> <id>onboarding</id> <activation> <activeByDefault>false</activeByDefault> </activation> <modules> <module>onboarding</module> </modules> </profile> <profile> <id>fast-build</id> <activation> <activeByDefault>false</activeByDefault> </activation> <properties> <maven.test.skip>true</maven.test.skip> <skipYamlJsonValidator>true</skipYamlJsonValidator> <checkstyle.skip>true</checkstyle.skip> <jacoco.skip>true</jacoco.skip> </properties> <modules> <module>ui-ci</module> <module>asdctool</module> <module>common-be</module> <module>onboarding</module> <module>catalog-be</module> <module>catalog-ui</module> <module>catalog-fe</module> <module>catalog-dao</module> <module>sdc-os-chef</module> <module>test-apis-ci</module> <module>catalog-model</module> <module>common-app-api</module> <module>common-app-logging</module> </modules> </profile> </profiles> <repositories> <!-- LF repositories --> <repository> <id>ecomp-releases</id> <name>Release Repository</name> <url>${nexus.proxy}/content/repositories/releases/</url> </repository> <repository> <id>ecomp-snapshots</id> <name>Snapshots Repository</name> <url>${nexus.proxy}/content/repositories/snapshots/</url> </repository> <repository> <id>ecomp-public</id> <name>Public Repository</name> <url>${nexus.proxy}/content/repositories/public/</url> </repository> <!-- LF repositories END--> </repositories> <distributionManagement> <repository> <id>ecomp-releases</id> <name>Release Repository</name> <url>${nexus.proxy}/content/repositories/releases/</url> </repository> <snapshotRepository> <id>ecomp-snapshots</id> <name>Snapshot Repository</name> <url>${nexus.proxy}/content/repositories/snapshots/</url> </snapshotRepository> <site> <id>ecomp-site</id> <url>dav:${nexus.proxy}${sitePath}</url> </site> </distributionManagement> </project>