1
|
|
|
import {defineConfig} from 'vite'; |
2
|
|
|
import {createVuePlugin} from 'vite-plugin-vue2' |
3
|
|
|
import ViteRestart from 'vite-plugin-restart'; |
4
|
|
|
import {viteExternalsPlugin} from 'vite-plugin-externals' |
5
|
|
|
import viteCompression from 'vite-plugin-compression'; |
6
|
|
|
import manifestSRI from 'vite-plugin-manifest-sri'; |
7
|
|
|
import {visualizer} from 'rollup-plugin-visualizer'; |
8
|
|
|
import eslintPlugin from 'vite-plugin-eslint'; |
9
|
|
|
import {nodeResolve} from '@rollup/plugin-node-resolve'; |
10
|
|
|
import * as path from 'path'; |
11
|
|
|
|
12
|
|
|
// https://vitejs.dev/config/ |
13
|
|
|
export default defineConfig((({command}) => ({ |
14
|
|
|
base: command === 'serve' ? '' : '/dist/', |
15
|
|
|
build: { |
16
|
|
|
emptyOutDir: true, |
17
|
|
|
manifest: true, |
18
|
|
|
outDir: '../src/web/assets/dist', |
19
|
|
|
rollupOptions: { |
20
|
|
|
input: { |
21
|
|
|
'imageoptimize': 'src/js/ImageOptimize.js', |
22
|
|
|
'field': 'src/js/OptimizedImagesField.js', |
23
|
|
|
'welcome': 'src/js/Welcome.js', |
24
|
|
|
}, |
25
|
|
|
output: { |
26
|
|
|
sourcemap: true |
27
|
|
|
}, |
28
|
|
|
} |
29
|
|
|
}, |
30
|
|
|
plugins: [ |
31
|
|
|
nodeResolve({ |
32
|
|
|
moduleDirectories: [ |
33
|
|
|
path.resolve('./node_modules'), |
34
|
|
|
], |
35
|
|
|
}), |
36
|
|
|
ViteRestart({ |
37
|
|
|
reload: [ |
38
|
|
|
'./src/templates/**/*', |
39
|
|
|
], |
40
|
|
|
}), |
41
|
|
|
createVuePlugin(), |
42
|
|
|
viteExternalsPlugin({ |
43
|
|
|
'vue': 'Vue', |
44
|
|
|
}), |
45
|
|
|
viteCompression({ |
46
|
|
|
filter: /\.(js|mjs|json|css|map)$/i |
47
|
|
|
}), |
48
|
|
|
manifestSRI(), |
49
|
|
|
visualizer({ |
50
|
|
|
filename: '../src/web/assets/dist/stats.html', |
51
|
|
|
template: 'treemap', |
52
|
|
|
sourcemap: true, |
53
|
|
|
}), |
54
|
|
|
eslintPlugin({ |
55
|
|
|
cache: false, |
56
|
|
|
}), |
57
|
|
|
], |
58
|
|
|
publicDir: '../src/web/assets/public', |
59
|
|
|
resolve: { |
60
|
|
|
alias: { |
61
|
|
|
'@': path.resolve(__dirname, './src'), |
62
|
|
|
'vue': 'vue/dist/vue.esm.js', |
63
|
|
|
}, |
64
|
|
|
preserveSymlinks: true, |
65
|
|
|
}, |
66
|
|
|
server: { |
67
|
|
|
fs: { |
68
|
|
|
strict: false |
69
|
|
|
}, |
70
|
|
|
host: '0.0.0.0', |
71
|
|
|
origin: 'http://localhost:3001/', |
72
|
|
|
port: 3001, |
73
|
|
|
strictPort: true, |
74
|
|
|
} |
75
|
|
|
})); |
76
|
|
|
|