Skip to content

Commit

Permalink
Merge pull request #44 from allyoucanmap/imp-webpack
Browse files Browse the repository at this point in the history
Introduce the support for local development with remote host
  • Loading branch information
Alessio Fabiani authored Feb 27, 2020
2 parents 22744fb + 6108223 commit e74d801
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 45 deletions.
4 changes: 2 additions & 2 deletions geonode_mapstore_client/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
97 changes: 54 additions & 43 deletions geonode_mapstore_client/client/webpack.config.js
Original file line number Diff line number Diff line change
@@ -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/'
}
}
}
]
}
});
});

0 comments on commit e74d801

Please sign in to comment.