Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
115 lines (112 loc) · 3.18 KB
/
Copy pathvite.config.ts
File metadata and controls
115 lines (112 loc) · 3.18 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/// <reference types="vite-plus/test" />
import { defineConfig } from 'vite-plus'
import type { Plugin } from 'vite-plus'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
import laravel from 'laravel-vite-plugin'
import { resolve } from 'path'
import { createHash } from 'crypto'
import { visualizer } from 'rollup-plugin-visualizer'
const projectRoot = import.meta.dirname
const writeBuildId = (): Plugin => ({
name: 'koel:build-id',
apply: 'build',
generateBundle(_options, bundle) {
const buildId = createHash('sha256').update(Object.keys(bundle).sort().join('\n')).digest('hex').slice(0, 16)
this.emitFile({ type: 'asset', fileName: 'build-id', source: buildId })
},
})
export default defineConfig({
staged: {
'**/*.php': ['composer cs'],
'resources/assets/**/*.{js,ts,css,pcss,vue}': ['vp check --fix'],
},
fmt: {
semi: false,
singleQuote: true,
arrowParens: 'avoid',
printWidth: 120,
objectWrap: 'preserve',
ignorePatterns: ['resources/assets/css/vendor/**', 'resources/assets/js/visualizers/**'],
},
lint: {
plugins: ['typescript', 'vue', 'import'],
categories: {
correctness: 'error',
suspicious: 'warn',
pedantic: 'off',
nursery: 'off',
style: 'off',
perf: 'warn',
restriction: 'off',
},
rules: {
'no-case-declarations': 'off',
'no-new': 'off',
'no-shadow': 'off',
'no-unused-expressions': 'off',
'no-unassigned-import': 'off',
'no-await-in-loop': 'off',
'typescript/ban-ts-comment': 'off',
'no-unsafe-type-assertion': 'off',
'no-unnecessary-type-assertion': 'off',
'no-unnecessary-type-arguments': 'off',
'no-unnecessary-type-parameters': 'off',
'no-floating-promises': 'off',
'unbound-method': 'off',
'restrict-template-expressions': 'off',
'no-redundant-type-constituents': 'off',
'no-duplicate-type-constituents': 'off',
'no-base-to-string': 'off',
'await-thenable': 'off',
},
ignorePatterns: [
'resources/assets/tsconfig.json',
'resources/assets/css/vendor/**',
'resources/assets/js/visualizers/**',
],
options: {
typeAware: true,
// TODO: enable typeCheck once tsgolint supports tsconfig paths resolution
// typeCheck: true,
},
},
plugins: [
vue(),
tailwindcss(),
...(process.env.VITEST
? []
: [
laravel({
input: ['resources/assets/js/app.ts', 'resources/assets/js/remote/app.ts'],
refresh: true,
}),
writeBuildId(),
visualizer({
filename: 'stats.html',
}),
]),
],
build: {
cssMinify: 'esbuild',
assetsInlineLimit: 0,
},
resolve: {
alias: {
'@': resolve(projectRoot, './resources/assets/js'),
'@modules': resolve(projectRoot, './node_modules'),
lodash: 'lodash-es',
},
},
test: {
environment: 'jsdom',
pool: 'vmThreads',
vmMemoryLimit: '300MB',
setupFiles: resolve(projectRoot, './resources/assets/js/__tests__/setup.ts'),
server: {
deps: {
cacheDir: resolve(projectRoot, 'node_modules/.vitest'),
},
},
},
})