-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
43 lines (36 loc) · 1.21 KB
/
webpack.config.ts
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
41
42
43
import fs from 'fs'
import path from 'path'
import * as dotenv from 'dotenv'
import type { BuildEnv, Paths } from './config/webpack'
import { webpackConfig } from './config/webpack'
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin')
dotenv.config()
const env: BuildEnv = process.env as unknown as BuildEnv
const isDev = env.NODE_ENV !== 'production'
const mode = isDev ? 'development' : 'production'
const port = +env.PORT
const paths: Paths = {
assets: path.resolve(__dirname, 'public', 'assets'),
bootImport: path.resolve(__dirname, 'config', 'boot_imports'),
build: path.resolve(__dirname, 'build'),
entry: path.resolve(__dirname, 'src', 'index.tsx'),
html: path.resolve(__dirname, 'public', 'index.html'),
checkBrowsers: path.resolve(__dirname, 'public', 'assets', 'js', 'check_browser_support'),
root: __dirname,
src: path.resolve(__dirname, 'src'),
}
const smp = new SpeedMeasurePlugin({
disable: !isDev,
})
const version = fs.readFileSync(path.resolve(paths.root, 'VERSION'), 'utf-8').trim()
console.log('Версия фронтенда >>>', version)
env.VERSION = version
const config = webpackConfig({
env,
isDev,
mode,
paths,
port,
version
})
export default smp.wrap(config)