Skip to content

Commit

Permalink
add environment variable controls to webpack (#756)
Browse files Browse the repository at this point in the history
- TRACKER_API_HOST for /api/ calls
- TRACKER_HOST for anything else (incl /api/ if not otherwise specified)
- STATIC_ROOT to override the path for the webpack templates

[#188744555]
  • Loading branch information
uraniumanchor authored Jan 5, 2025
1 parent 150abc3 commit 356ee36
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const SOURCE_MAPS = process.env.SOURCE_MAPS ?? false;
const ANALYZE = process.env.ANALYZE ?? false;
const NO_MANIFEST = !!process.env.NO_MANIFEST ?? false;
const PROJECT_ROOT = __dirname;
const STATIC_ROOT = process.env.STATIC_ROOT ?? '/static/gen';

console.log(PROD ? 'PRODUCTION BUILD' : 'DEVELOPMENT BUILD');

Expand Down Expand Up @@ -47,7 +48,7 @@ module.exports = {
filename: PROD ? 'tracker-[name]-[contenthash].js' : 'tracker-[name].js',
pathinfo: true,
path: PROJECT_ROOT + '/tracker/static/gen',
publicPath: '/static/gen',
publicPath: STATIC_ROOT,
},
stats: 'minimal',
module: {
Expand Down Expand Up @@ -152,8 +153,15 @@ module.exports = {
: {
proxy: [
{
context: ['/admin', '/logout', '/api', '/ui', '/static', '/tracker', '/donate', '/media'],
context: ['/tracker/api'],
target: process.env.TRACKER_API_HOST || process.env.TRACKER_HOST || 'http://127.0.0.1:8000/',
changeOrigin: !!(process.env.TRACKER_API_HOST || process.env.TRACKER_HOST),
},
{
context: ['/admin', '/logout', '/ui', '/static', '/tracker', '/donate', '/media'],
target: process.env.TRACKER_HOST || 'http://127.0.0.1:8000/',
changeOrigin: !!process.env.TRACKER_HOST,
cookieDomainRewrite: '',
ws: true,
},
],
Expand Down

0 comments on commit 356ee36

Please sign in to comment.