forked from Tucsky/aggr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
123 lines (114 loc) · 3 KB
/
vite.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue2'
// import { createVuePlugin } from 'vite-plugin-vue2' // Vue <= 2.6
import { visualizer } from 'rollup-plugin-visualizer'
import { VitePWA } from 'vite-plugin-pwa'
import svgLoader from 'vite-svg-loader'
import eslint from 'vite-plugin-eslint';
import fs from 'fs'
import path from 'path'
// const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin')
// const WebpackPwaManifest = require('webpack-pwa-manifest')
import gitprocess from 'child_process'
// Make build date
const makeBuildDate = function (): string {
const date = new Date(
gitprocess
.execSync('git log -1 --date=format:"%Y/%m/%d %T" --format="%ad"')
.toString()
)
return (
`${date.getDate()} ` +
`${date.toLocaleString('en-US', { month: 'short' }).toLowerCase()}`
)
}
// Make string with available exchanges from workers
const makeExchangeList = (): string => {
const exchanges: string[] = []
fs.readdirSync('./src/worker/exchanges/').forEach(file => {
if (/\w+\.ts$/.test(file) && file !== 'index.ts') {
exchanges.push(file.replace(/\.ts$/, ''))
}
})
return exchanges.join(',')
}
const {
NODE_ENV,
API_URL,
PROXY_URL,
DEV_PROXY_URL,
API_SUPPORTED_PAIRS,
API_SUPPORTED_TIMEFRAMES,
PUBLIC_PATH,
PUBLIC_VAPID_KEY
} = process.env
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
define: {
VITE_APP_BUILD_DATE: makeBuildDate(),
VITE_APP_PROXY_URL: env.PROXY_URL,
VITE_APP_API_URL: env.API_URL
},
plugins: [
eslint(),
vue(),
// createVuePlugin(), // Vue <= 2.6
svgLoader({
defaultImport: 'url', // 👈
}),
visualizer(),
VitePWA({
srcDir: 'src',
filename: 'sw.js',
registerType: 'autoUpdate',
includeAssets: [
'favicon-32x32.png',
'favicon-16x16.png',
'apple-touch-icon.png',
'safari-pinned-tab.svg'
],
manifest: {
name: 'SignificantTrades',
short_name: 'AGGR',
description: 'Cryptocurrency market trades aggregator',
theme_color: '#171b29',
icons: [
{
src: 'android-chrome-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: 'android-chrome-512x512.png',
sizes: '512x512',
type: 'image/png'
}
]
}
})
],
server: {
port: 8080
},
resolve: {
alias: [
{
find: '@',
replacement: path.resolve(__dirname, 'src')
}
]
},
outputDir:{
},
css: {
preprocessorOptions: {
scss: {
// example : additionalData: `@import "./src/design/styles/variables";`
// dont need include file extend .scss
additionalData: `@import "@/assets/sass/variables.scss";`
}
}
}
}
})