From 61082239d4d3f2ead699f07bc29444e646f6229e Mon Sep 17 00:00:00 2001 From: allyoucanmap Date: Wed, 26 Feb 2020 17:23:36 +0100 Subject: [PATCH] change dev server host to develop without a local geonode --- geonode_mapstore_client/client/package.json | 4 +- .../client/webpack.config.js | 97 +++++++++++-------- 2 files changed, 56 insertions(+), 45 deletions(-) diff --git a/geonode_mapstore_client/client/package.json b/geonode_mapstore_client/client/package.json index c5082b0ad8..8fc5c66e1d 100644 --- a/geonode_mapstore_client/client/package.json +++ b/geonode_mapstore_client/client/package.json @@ -260,12 +260,12 @@ "ag-grid-community": "20.2.0", "connected-react-router": "6.3.2", "istanbul-instrumenter-loader": "3.0.1", - "react-checkbox-tree": "^1.5.1", + "react-checkbox-tree": "1.5.1", "react-contenteditable": "3.3.2", "react-dnd-test-backend": "2.6.0", "react-error-boundary": "1.2.5", "react-grid-layout": "0.16.6", - "react-horizontal-scrolling-menu": "^0.7.3", + "react-horizontal-scrolling-menu": "0.7.3", "react-resize-detector": "4.2.1" } } diff --git a/geonode_mapstore_client/client/webpack.config.js b/geonode_mapstore_client/client/webpack.config.js index 1e56f849f5..880e548d19 100644 --- a/geonode_mapstore_client/client/webpack.config.js +++ b/geonode_mapstore_client/client/webpack.config.js @@ -1,68 +1,79 @@ -const path = require("path"); -const assign = require("object-assign"); +const path = require('path'); +const assign = require('object-assign'); const themeEntries = { - "themes/default": path.join(__dirname, "themes", "default", "theme.less"), - "themes/preview": path.join(__dirname, "themes", "preview", "theme.less") + 'themes/default': path.join(__dirname, 'themes', 'default', 'theme.less'), + 'themes/preview': path.join(__dirname, 'themes', 'preview', 'theme.less') }; const extractThemesPlugin = require('./MapStore2/build/themes.js').extractThemesPlugin; -module.exports = assign({}, require('./MapStore2/build/buildConfig')({ - 'ms2-geonode-api': path.join(__dirname, "js", "api") +const DEV_SERVER_HOST = 'ERROR:INSERT_DEV_SERVER_HOST_IN_WEBPACK_CONFIG! eg: my-geonode-host.org'; + +module.exports = assign({}, require('./MapStore2/build/buildConfig')( + { + 'ms2-geonode-api': path.join(__dirname, 'js', 'api') }, - themeEntries, { + themeEntries, + { base: __dirname, - dist: path.join(__dirname, "dist"), - framework: path.join(__dirname, "MapStore2", "web", "client"), - code: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")] + dist: path.join(__dirname, 'dist'), + framework: path.join(__dirname, 'MapStore2', 'web', 'client'), + code: [path.join(__dirname, 'js'), path.join(__dirname, 'MapStore2', 'web', 'client')] }, extractThemesPlugin, false, - "http://localhost:8081/dist/", + '/static/mapstore/dist/', '.msgapi' ), { devServer: { - headers: { 'Access-Control-Allow-Origin': '*' }, - proxy: { - '/rest/geostore': { - target: "https://dev.mapstore.geo-solutions.it/mapstore", - secure: false, - headers: { - host: "dev.mapstore.geo-solutions.it" - } - }, - '/pdf': { - logLevel: "debug", - target: "https://dev.mapstore.geo-solutions.it/mapstore", - secure: false, - headers: { - host: "dev.mapstore.geo-solutions.it" + contentBase: [ + path.join(__dirname), + path.join(__dirname, '..', 'static') + ], + setup: function(app) { + const hashRegex = /\.[a-zA-Z0-9]{1,}\.js/; + app.use(function(req, res, next) { + // remove hash from requests to use the local js + if (req.url.indexOf('/static/geonode/js/ms2/utils/') !== -1 + || req.url.indexOf('/ms2-geonode-api') !== -1) { + req.url = req.url.replace(hashRegex, '.js'); + req.path = req.path.replace(hashRegex, '.js'); + req.originalUrl = req.originalUrl.replace(hashRegex, '.js'); } - }, - '/mapstore/pdf': { - logLevel: "debug", - target: "https://dev.mapstore.geo-solutions.it", - secure: false, - headers: { - host: "dev.mapstore.geo-solutions.it" - } - }, - '/proxy': { - target: "http://localhost:8000", + next(); + }); + }, + proxy: [ + { + context: [ + '**', + '!**/static/mapstore/**', + '!**/static/geonode/js/ms2/utils/**', + '!**/geonode/js/ms2/utils/**', + '!**/MapStore2/**', + '!**/node_modules/**' + ], + target: `https://${DEV_SERVER_HOST}`, secure: false, + changeOrigin: true, headers: { - host: "dev.mapstore.geo-solutions.it" + host: DEV_SERVER_HOST } }, - '/docs': { - target: "http://localhost:8081", + { + context: [ + '/static/mapstore/MapStore2/web/client/translations/**', + '/static/geonode/js/ms2/utils/**' + ], + target: 'http://localhost:8081', pathRewrite: { - '/docs': '/mapstore/docs' + '/static/mapstore/MapStore2/web/client/translations/': '/MapStore2/web/client/translations/', + '/static/geonode/js/ms2/utils/': '/geonode/js/ms2/utils/' } } - } + ] } -}); \ No newline at end of file +});