-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
55 lines (49 loc) · 1.44 KB
/
vite.config.js
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
import { resolve } from 'path';
import { defineConfig } from 'vite';
import indexHandlebarsPlugin from 'vite-plugin-handlebars';
import mpa from 'vite-plugin-mpa';
import topLevelAwait from 'vite-plugin-top-level-await';
import wasm from 'vite-plugin-wasm';
import markdownPlugin from './vite/markdownPlugin';
const markdown = require('helper-markdown');
const Settings = require('./settings.json');
// https://vitejs.dev/config/
export default defineConfig(async () => {
const base = process.env.APP_BASE_URL || '/';
const handlebarsOptions = {
// eslint-disable-next-line no-undef
partialDirectory: resolve(__dirname, 'src/layout'),
// context: { settings: Settings },
context: (pagePath) => {
Settings['trainTutorialSteps'].forEach((element) => {
element.baseUrl = base;
});
return { baseUrl: base, settings: Settings };
},
reloadOnPartialChange: true,
helpers: {
markdown: (value) => markdown(value),
ifEquals: function (arg1, arg2, options) {
return arg1 == arg2 ? options.fn(this) : options.inverse(this);
},
},
}
return {
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
plugins: [
wasm(),
topLevelAwait(),
mpa(),
indexHandlebarsPlugin(handlebarsOptions),
markdownPlugin(handlebarsOptions)
],
base,
optimizeDeps: {
exclude: ['@tensorflow/tfjs-backend-wasm/dist'],
},
};
});