Skip to content

Commit

Permalink
feat: add api url func
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Apr 6, 2024
1 parent eb198bc commit 33f6f39
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import webpack from 'webpack';
import path from 'path';
import { buildWebpackConfig } from './config/build/buildWebpackConfig';
import { BuildEnv, BuildPaths } from './config/build/types/config';
import { BuildEnv, BuildMode, BuildPaths } from './config/build/types/config';

function getApiUrl(mode: BuildMode, apiUrl?: string) {
if (apiUrl) {
return apiUrl;
}
if (mode === 'production') {
return '/api';
}

return 'http://localhost:8000';
}

export default (env: BuildEnv) => {
const paths: BuildPaths = {
Expand All @@ -17,7 +28,7 @@ export default (env: BuildEnv) => {
const PORT = env?.port || 3000;

const isDev = mode === 'development';
const apiUrl = env?.apiUrl || 'http://localhost:8000';
const apiUrl = getApiUrl(mode, env?.apiUrl);

const config: webpack.Configuration = buildWebpackConfig({
mode,
Expand Down

0 comments on commit 33f6f39

Please sign in to comment.