This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #332 from multinet-app/best_practices
Remove use of DefinePlugin, switch to VUE_APP env vars
- Loading branch information
Showing
8 changed files
with
1,202 additions
and
1,138 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Usually auto-injected | ||
VUE_APP_GIT_SHA= | ||
VUE_APP_GA_TAG= | ||
|
||
# Must contain protocol prefix (http://, https://, etc.) | ||
VUE_APP_MULTINET_HOST= |
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,9 +1,6 @@ | ||
import { multinetApi } from 'multinet'; | ||
import { host } from '@/environment'; | ||
|
||
function getApiRoot() { | ||
return `${window.location.origin}/api`; | ||
} | ||
|
||
const api = multinetApi(getApiRoot()); | ||
const api = multinetApi(`${host}/api`); | ||
|
||
export default api; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const host: string = process.env.VUE_APP_MULTINET_HOST || 'http://localhost:5000'; | ||
export const gaTag: string = process.env.VUE_APP_GA_TAG || ''; | ||
export const gitSha: string = process.env.VUE_APP_GIT_SHA || ''; |
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,50 +1,9 @@ | ||
const fs = require('fs'); | ||
const process = require('process'); | ||
const path = require('path'); | ||
const dotenv = require('dotenv'); | ||
const webpack = require('webpack'); | ||
|
||
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin'); | ||
|
||
function fileToJsonString(filename) { | ||
let result = null; | ||
if (fs.existsSync(filename)) { | ||
result = JSON.stringify(fs.readFileSync(filename).toString().trim()); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
// Read in .env file. | ||
const env = dotenv.parse(fs.readFileSync(path.resolve('..', '.env'))); | ||
process.env.FLASK_SERVE_PORT = process.env.FLASK_SERVE_PORT || env.FLASK_SERVE_PORT || 5000; | ||
|
||
// Look for a git-sha file; if found, inject the value found in it into the | ||
// application. | ||
const GIT_SHA = fileToJsonString('git-sha'); | ||
|
||
// Inject a value for gaTag (google analytics) if present as well. | ||
const GA_TAG = fileToJsonString('ga-tag'); | ||
|
||
module.exports = { | ||
configureWebpack: { | ||
plugins: [ | ||
new VuetifyLoaderPlugin(), | ||
new webpack.DefinePlugin({ | ||
GIT_SHA, | ||
GA_TAG, | ||
}), | ||
], | ||
}, | ||
devServer: { | ||
proxy: { | ||
'/api': { | ||
target: `http://127.0.0.1:${process.env.FLASK_SERVE_PORT}/api`, | ||
changeOrigin: true, | ||
pathRewrite: { | ||
'^/api': '', | ||
}, | ||
} | ||
} | ||
} | ||
}; |
Oops, something went wrong.