forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from allyoucanmap/imp-webpack
Introduce the support for local development with remote host
- Loading branch information
Showing
2 changed files
with
56 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/' | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}); | ||
}); |