Update ODLUX
[ccsdk/features.git] / sdnr / wt / odlux / apps / configurationApp / webpack.config.js
index e44b932..2f7ab11 100644 (file)
@@ -10,6 +10,9 @@ const path = require("path");
 const webpack = require("webpack");
 const CopyWebpackPlugin = require("copy-webpack-plugin");
 const TerserPlugin = require('terser-webpack-plugin');
+const proxyConf = require('../../proxy.conf');
+
+const policies = require('./policies.json');
 
 // const __dirname = (path => path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname());
 
@@ -26,7 +29,7 @@ module.exports = (env) => {
     context: path.resolve(__dirname, "src"),
 
     entry: {
-      configurationApp: ["./plugin.tsx"]
+      configurationApp: ["./pluginConfiguration.tsx"]
     },
 
     devtool: env === "release" ? false : "source-map",
@@ -38,7 +41,7 @@ module.exports = (env) => {
     output: {
       path: distPath,
       filename: "[name].js",
-      library: "[name]",
+      library: "configurationApp",
       libraryTarget: "umd2",
       chunkFilename: "[name].js"
     },
@@ -57,6 +60,16 @@ module.exports = (env) => {
         use: [{
           loader: "babel-loader"
         }]
+      },{
+        //don't minify images
+        test: /\.(png|gif|jpg|svg)$/,
+        use: [{
+          loader: 'url-loader',
+          options: {
+            limit: 10,
+            name: './images/[name].[ext]'
+          }
+        }]
       }]
     },
 
@@ -86,11 +99,7 @@ module.exports = (env) => {
         manifest: require(path.resolve(frameworkPath, "app-manifest.json")),
         sourceType: "umd2"
       }),
-      new CopyWebpackPlugin([{
-        from: "assets",
-        to: path.resolve(distPath, "assets")
-      }]),
-      ...(env === "release") ? [
+      ...(env === "release" ? [
         new webpack.DefinePlugin({
           "process.env": {
             NODE_ENV: "'production'",
@@ -108,11 +117,14 @@ module.exports = (env) => {
             from: 'index.html',
             to: distPath
           }]),
-        ]
+        ])
     ],
 
+     watchOptions: {
+       ignored: /node_modules/
+     },
+
     devServer: {
-      public: "http://localhost:3100",
       contentBase: frameworkPath,
 
       compress: true,
@@ -129,30 +141,10 @@ module.exports = (env) => {
       stats: {
         colors: true
       },
-      proxy: {
-        "/oauth2/": {
-          target: "http://localhost:3000",
-          secure: false
-        },
-        "/database/": {
-          target: "http://localhost:3000",
-          secure: false
-        },
-        "/restconf/": {
-          target: "http://localhost:3000",
-          secure: false
-        },
-        "/help/": {
-          target: "http://localhost:3000",
-          secure: false
-        },
-        "/websocket/": {
-          target: "http://localhost:3000",
-          ws: true,
-          changeOrigin: true,
-          secure: false
-        }
-      }
+      before: function(app, server, compiler) {
+        app.get('/oauth/policies',(_, res) => res.json(policies));
+      },
+      proxy: proxyConf,
     }
   }];
 }