-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.ts
More file actions
40 lines (33 loc) · 1.15 KB
/
webpack.config.ts
File metadata and controls
40 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { type Configuration } from 'webpack';
import * as path from 'path';
import * as dotenv from 'dotenv';
import { buildWebpackConfig } from './config/build/buildWebpackConfig';
import { type BuildEnv, type BuildPaths } from './config/build/types/config';
export default (env: BuildEnv) => {
const paths: BuildPaths = {
build: path.resolve(__dirname, 'build'),
entry: path.resolve(__dirname, 'src', 'index.tsx'),
html: path.resolve(__dirname, 'public', 'index.html'),
src: path.resolve(__dirname, 'src'),
locales: path.resolve(__dirname, 'public', 'locales'),
buildLocales: path.resolve(__dirname, 'build', 'locales'),
assets: path.resolve(__dirname, 'public', 'assets'),
buildAssets: path.resolve(__dirname, 'build', 'assets'),
};
const mode = env.mode || 'development';
if (mode === 'production') {
dotenv.config();
}
const PORT = env.port || 3000;
const apiUrl = process.env.apiUrl || 'http://localhost:8000';
const isDev = mode === 'development';
const config: Configuration = buildWebpackConfig({
mode,
paths,
isDev,
port: PORT,
apiUrl,
project: 'frontend',
});
return config;
};