-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.js
105 lines (98 loc) · 3.2 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
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
import { defineConfig, loadEnv } from "vite";
import dynamicImport from 'vite-plugin-dynamic-import'
import legacy from '@vitejs/plugin-legacy';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import vue from '@vitejs/plugin-vue'
import path from 'path';
import tailwindcss from '@tailwindcss/vite';
import checker from 'vite-plugin-checker';
// Match ports in .ddev/config.yaml -> web_extra_exposed_ports
const HTTP_PORT = 3000;
const HTTPS_PORT = 3001;
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const origin = env.PRIMARY_SITE_URL ?? 'https://localhost';
let plugins = [
tailwindcss(),
dynamicImport(),
legacy({
targets: ['defaults', 'not IE 11']
}),
checker({
eslint: {
lintCommand: 'eslint "./src/scripts/**/*.{vue,js,jsx,mjs}"',
useFlatConfig: true
},
stylelint : {
lintCommand: 'stylelint "./src/styles/**/*.{css,scss}"',
},
}),
viteStaticCopy({
targets: [
{
src: 'src/static',
dest: ''
}
]
}),
vue(),
];
return {
base: command === 'serve' ? '' : '/dist/',
build: {
emptyOutDir: true,
manifest: true,
outDir: './web/dist/',
rollupOptions: {
input: {
app: './src/scripts/main.js',
},
output: {
/*
Optionally, manually separate out a vendor chunk containing
modules imported by lots of your components
manualChunks: (id) => {
if (id.includes("node_modules")) {
if (id.includes('alpine')
|| id.includes('lazysizes')
|| id.includes('pubsub-js')
|| id.includes('vue')
) {
return "vendor";
}
}
},
*/
}
},
},
plugins: plugins,
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@css': path.resolve(__dirname, 'src/styles'),
'@js': path.resolve(__dirname, 'src/scripts'),
'@assets': path.resolve(__dirname, 'src/assets'),
},
},
server: {
allowedHosts: true,
cors: { origin: origin },
host: '0.0.0.0',
origin: origin + ':' + HTTPS_PORT,
port: HTTP_PORT,
strictPort: true,
watch: {
ignored: [
"**/storage/**",
"**/web/**",
"**/vendor/**",
`${__dirname}/.idea/**`,
`${__dirname}/.stylelintcache/**`,
`${__dirname}/.eslintcache/**`
],
},
}
}
});