Repository navigation
Expand file tree
/
Copy pathvite.config.js
More file actions
82 lines (78 loc) · 2.27 KB
/
Copy pathvite.config.js
File metadata and controls
82 lines (78 loc) · 2.27 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
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import { viteSingleFile } from 'vite-plugin-singlefile'
import tailwindcss from '@tailwindcss/vite'
import path from 'node:path'
import fsp from 'node:fs/promises'
import { getProjectLicenses } from 'generate-license-file'
const buildPath = './build'
const generatedLicensePath = path.join(buildPath, 'LicensePage.vue')
export default defineConfig({
// prettier-ignore
plugins: [
vue(),
vueDevTools(),
viteSingleFile(),
tailwindcss(),
{
name: 'generate-license-page',
buildStart: async () => {
console.log('Creating build folder...')
await fsp.mkdir(buildPath, { recursive: true })
console.log('Generating license page...')
const ourLicense = await fsp.readFile('./LICENSE.md', 'utf-8')
const thirdPartyLicenses = await getProjectLicenses("./package.json")
await fsp.writeFile(
generatedLicensePath,
`<template>
<pre class="mt-0 text-neutral bg-base-100">${ourLicense}</pre>
<div class="collapse collapse-arrow border border-base-300">
<input type="checkbox" />
<div class="collapse-title font-semibold">Third-Party Licenses</div>
<div class="collapse-content text-sm overflow-x-auto">
${
thirdPartyLicenses
.map(
(license) =>
` <div class="mt-4">
<h4 class="mt-0">${license.dependencies.join(', ')}</h4>
<pre class="mt-0 ml-2 text-neutral bg-base-100">${license.content.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''')}</pre>
</div>
`
)
.join('\n')
}
</div>
</div>
</template>`
)
},
closeBundle: async () => {
console.log('Removing build folder...')
await fsp.rm(buildPath, { recursive: true, force: true })
}
}
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
port: 3000,
open: '/nortek-ad2cp-reader.html',
},
build: {
rollupOptions: {
input: {
app: './nortek-ad2cp-reader.html',
},
},
},
})