-
Notifications
You must be signed in to change notification settings - Fork 10
/
vite.config.mts
101 lines (99 loc) · 2.7 KB
/
vite.config.mts
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
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
// import legacy from '@vitejs/plugin-legacy';
import ViteRestart from 'vite-plugin-restart';
import viteCompression from 'vite-plugin-compression';
import manifestSRI from 'vite-plugin-manifest-sri';
import { visualizer } from 'rollup-plugin-visualizer';
import eslintPlugin from 'vite-plugin-eslint';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import critical from 'rollup-plugin-critical';
import { ViteFaviconsPlugin } from 'vite-plugin-favicon2';
import * as path from 'path';
import copy from 'rollup-plugin-copy';
// https://vitejs.dev/config/
export default defineConfig(({ command }) => ({
base: command === 'serve' ? '' : '/dist/',
esbuild: {
drop: command === 'build' ? ['console', 'debugger'] : [],
},
build: {
emptyOutDir: true,
manifest: true,
outDir: path.resolve('./web/dist'),
rollupOptions: {
input: {
app: './src/js/app.ts',
},
},
sourcemap: true,
},
plugins: [
critical({
criticalUrl: 'https://stage.baukasten.io/',
criticalBase: './web/dist/criticalcss/',
criticalPages: [
{ uri: '', template: 'index' },
{ uri: 'content-builder', template: 'entry/pages/contentBuilder' },
],
criticalConfig: {
width: 1680,
height: 1200,
},
}),
// legacy({
// targets: ['defaults', 'not IE 11'],
// }),
nodeResolve({
moduleDirectories: ['node_modules'],
}),
ViteFaviconsPlugin({
logo: './src/public/images/favicon-src.svg',
inject: false,
outputPath: 'favicons-default',
favicons: {
appName: 'craftcms-baukasten',
lang: 'de',
background: '#244F43',
theme_color: '#244F43',
},
}),
ViteRestart({
reload: ['./translations/**/*.php', './templates/**/*.{twig,html,php}'],
}),
vue(),
viteCompression({
filter: /\.(js|mjs|json|css|map)$/i,
}),
manifestSRI(),
visualizer({
filename: './web/dist/assets/stats.html',
template: 'treemap',
sourcemap: true,
}),
eslintPlugin({
cache: false,
}),
copy({
targets: [{ src: 'src/public/*', dest: 'web/dist' }],
hook: command === 'build' ? 'writeBundle' : 'buildStart',
copyOnce: true,
}),
],
publicDir: './src/public',
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js',
'@': path.resolve('./src'),
'@templates': path.resolve('./templates'),
'@components': path.resolve('./templates/_components'),
},
},
// Use this for Laravel Valet
server: {
host: '0.0.0.0',
origin: 'http://localhost:3100',
port: 3100,
strictPort: true,
},
}));