[mod] make production webapp work as well

This commit is contained in:
2020-05-03 16:06:32 +02:00
parent e745668f66
commit e99f12d233
3 changed files with 15 additions and 4 deletions

View File

@@ -19,7 +19,7 @@
} }
}, },
async created() { async created() {
const dwatcherAPI = api('http://localhost:10501') const dwatcherAPI = api()
this.watchers = await dwatcherAPI.getStatus() this.watchers = await dwatcherAPI.getStatus()
}, },

View File

@@ -1,9 +1,9 @@
import * as axios from "axios"; import * as axios from "axios";
export function api(baseURL) { export function api() {
const instance = axios.default.create({ const instance = axios.default.create({
baseURL baseURL: __API__
}) })
return { return {

View File

@@ -1,8 +1,16 @@
const webpack = require("webpack");
const path = require('path'); const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin') const VueLoaderPlugin = require('vue-loader/lib/plugin')
let __API__ = "'http://localhost:10501'"
if (process.env.NODE_ENV === 'production') {
__API__ = "'/'"
}
module.exports = { module.exports = {
context: path.resolve(__dirname, './src/webapp/'), context: path.resolve(__dirname, './src/webapp/'),
entry: './index.js', entry: './index.js',
@@ -16,7 +24,10 @@ module.exports = {
title: 'Output Management', title: 'Output Management',
template: 'index.html' template: 'index.html'
}), }),
new VueLoaderPlugin() new VueLoaderPlugin(),
new webpack.DefinePlugin({
__API__
})
], ],
module: { module: {
rules: [ rules: [