From 7f9e132cf40f16c8caa98f6b5270a44cece37d97 Mon Sep 17 00:00:00 2001 From: konrad Date: Thu, 23 Nov 2017 15:20:52 +0100 Subject: [PATCH] Added config for apit endpoint --- frontend/build/webpack.base.conf.js | 10 ++++++++++ frontend/package.json | 16 ++++++++-------- frontend/siteconfig.json | 3 +++ frontend/src/http-common/index.js | 5 ++++- 4 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 frontend/siteconfig.json diff --git a/frontend/build/webpack.base.conf.js b/frontend/build/webpack.base.conf.js index d07d3f0..ae9c245 100644 --- a/frontend/build/webpack.base.conf.js +++ b/frontend/build/webpack.base.conf.js @@ -3,6 +3,7 @@ const path = require('path') const utils = require('./utils') const config = require('../config') const vueLoaderConfig = require('./vue-loader.conf') +const CopyWebpackPlugin = require('copy-webpack-plugin'); function resolve (dir) { return path.join(__dirname, '..', dir) @@ -27,6 +28,15 @@ module.exports = { 'semantic': path.resolve(__dirname, '../node_modules/semantic-ui-css/semantic.min.js') } }, + plugins: [ + new CopyWebpackPlugin([ + // Copy directory contents to {output}/ + { from: './siteconfig.json' } + ]) + ], + externals: { + './siteconfig.json': "require('./siteconfig.json')" + }, module: { rules: [ { diff --git a/frontend/package.json b/frontend/package.json index b02b3b0..6b56bfd 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -33,17 +33,17 @@ "babel-register": "^6.22.0", "chalk": "^2.0.1", "connect-history-api-fallback": "^1.3.0", - "copy-webpack-plugin": "^4.0.1", + "copy-webpack-plugin": "^4.2.3", "css-loader": "^0.28.0", "eslint": "^3.19.0", + "eslint-config-standard": "^10.2.1", "eslint-friendly-formatter": "^3.0.0", "eslint-loader": "^1.7.1", "eslint-plugin-html": "^3.0.0", - "eslint-config-standard": "^10.2.1", - "eslint-plugin-promise": "^3.4.0", - "eslint-plugin-standard": "^3.0.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-node": "^5.2.0", + "eslint-plugin-promise": "^3.4.0", + "eslint-plugin-standard": "^3.0.1", "eventsource-polyfill": "^0.9.6", "express": "^4.14.1", "extract-text-webpack-plugin": "^3.0.0", @@ -51,19 +51,19 @@ "friendly-errors-webpack-plugin": "^1.6.1", "html-webpack-plugin": "^2.30.1", "http-proxy-middleware": "^0.17.3", - "webpack-bundle-analyzer": "^2.9.0", - "semver": "^5.3.0", - "shelljs": "^0.7.6", "opn": "^5.1.0", "optimize-css-assets-webpack-plugin": "^3.2.0", "ora": "^1.2.0", + "portfinder": "^1.0.13", "rimraf": "^2.6.0", + "semver": "^5.3.0", + "shelljs": "^0.7.6", "url-loader": "^0.5.8", "vue-loader": "^13.3.0", "vue-style-loader": "^3.0.1", "vue-template-compiler": "^2.5.2", - "portfinder": "^1.0.13", "webpack": "^3.6.0", + "webpack-bundle-analyzer": "^2.9.0", "webpack-dev-middleware": "^1.12.0", "webpack-hot-middleware": "^2.18.2", "webpack-merge": "^4.1.0" diff --git a/frontend/siteconfig.json b/frontend/siteconfig.json new file mode 100644 index 0000000..1ebae71 --- /dev/null +++ b/frontend/siteconfig.json @@ -0,0 +1,3 @@ +{ + "API_URL": "http://localhost:8082/api/v1/" +} diff --git a/frontend/src/http-common/index.js b/frontend/src/http-common/index.js index fde5214..4bd6e76 100644 --- a/frontend/src/http-common/index.js +++ b/frontend/src/http-common/index.js @@ -1,8 +1,11 @@ import axios from 'axios' // import auth from '../auth' +// import config from '../../static/config' +// import config from 'config' +let config = require('../../siteconfig.json') export const HTTP = axios.create({ - baseURL: `http://localhost:8082/api/v1/`, + baseURL: config.API_URL, headers: { 'Authorization': 'Bearer ' + localStorage.getItem('token') }