-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvite.config.js
More file actions
86 lines (80 loc) · 2.61 KB
/
vite.config.js
File metadata and controls
86 lines (80 loc) · 2.61 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
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
/* global process */
import { resolve } from 'path';
import dotenv from 'dotenv';
import { defineConfig } from 'vite';
import basicSsl from '@vitejs/plugin-basic-ssl';
import handlebarsCompiler from './plugins/handlebars-compiler.js';
import handlebarsPlugin from 'vite-plugin-handlebars';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons-ng';
import pkg from './package.json' with { type: 'json' };
import structuredData from './app/templates/includes/structuredData.json' with { type: 'json' };
structuredData.softwareVersion = pkg.version;
export default () => {
const __dirname = import.meta.dirname;
const root = resolve(__dirname, 'app');
dotenv.config({
path: resolve(root, '.env'),
quiet: true
});
const globals = {
__VERSION__: JSON.stringify(pkg.version),
NOTESREVIEW_API_URL: JSON.stringify(process.env.NOTESREVIEW_API_URL),
OPENSTREETMAP_SERVER: JSON.stringify(process.env.OPENSTREETMAP_SERVER),
OPENSTREETMAP_OAUTH_CLIENT_ID: JSON.stringify(process.env.OPENSTREETMAP_OAUTH_CLIENT_ID),
OPENSTREETMAP_OAUTH_CLIENT_SECRET: JSON.stringify(process.env.OPENSTREETMAP_OAUTH_CLIENT_SECRET),
MAPILLARY_CLIENT_ID: JSON.stringify(process.env.MAPILLARY_CLIENT_ID)
};
return defineConfig({
base: '/',
root,
define: globals,
build: {
sourcemap: true,
rolldownOptions: {
output: {
codeSplitting: {
groups: [{
test: /node_modules\/@rapideditor\/country-coder/,
name: 'country-coder',
}, {
test: /node_modules\/@rapideditor\/location-conflation/,
name: 'location-conflation',
}, {
test: /node_modules\/leaflet/,
name: 'leaflet',
}],
}
}
}
},
plugins: [
basicSsl(),
handlebarsCompiler({
globals: {
__VERSION__: pkg.version,
NOTESREVIEW_API_URL: process.env.NOTESREVIEW_API_URL,
OPENSTREETMAP_SERVER: process.env.OPENSTREETMAP_SERVER,
},
partials: {
actions: resolve(root, 'templates/dynamic/actions.hbs'),
}
}),
handlebarsPlugin({
partialDirectory: [
resolve(root, 'templates'),
resolve(root, 'templates/includes'),
resolve(root, 'templates/modals')
],
context: {
structuredData: JSON.stringify(structuredData),
version: pkg.version,
api: process.env.NOTESREVIEW_API_URL
}
}),
createSvgIconsPlugin({
iconDirs: [resolve(root, 'svg')],
symbolId: 'svg-[dir]-[name]'
})
]
});
};