Skip to content

Commit b13628a

Browse files
committed
Fixed vite.config.docs.ts.
1 parent 7f096da commit b13628a

File tree

2 files changed

+84
-56
lines changed

2 files changed

+84
-56
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<link rel="icon" href="/favicon.ico" />
77
<link
88
rel="stylesheet"
9-
href="https://cdn.jsdelivr.net/npm/[email protected].1/dist/css/bootstrap.min.css"
10-
integrity="sha256-KTPJY0ik6ufLv48oDKCYFYaptcCX75UrmWytfSjy+tA="
9+
href="https://cdn.jsdelivr.net/npm/[email protected].2/dist/css/bootstrap.min.css"
10+
integrity="sha256-IUOUHAPazai08QFs7W4MbzTlwEWFo7z/4zw8YmxEiko="
1111
crossorigin="anonymous"
1212
/>
1313
<title>Vue CodeMirror6 Demo</title>

vite.config.docs.ts

Lines changed: 82 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,95 @@
11
import { defineConfig, type UserConfig } from 'vite';
22
import { fileURLToPath } from 'url';
33
import checker from 'vite-plugin-checker';
4+
import fs from 'node:fs';
45
import Vue from '@vitejs/plugin-vue';
56

7+
const pkg = require('./package.json');
8+
69
// https://vitejs.dev/config/
7-
const config: UserConfig = {
8-
base: './',
9-
// Resolver
10-
resolve: {
11-
// https://vitejs.dev/config/#resolve-alias
12-
alias: {
13-
'@': fileURLToPath(new URL('./src', import.meta.url)),
14-
},
15-
},
16-
// https://vitejs.dev/config/#server-options
17-
server: {
18-
fs: {
19-
// Allow serving files from one level up to the project root
20-
allow: ['..'],
10+
export default defineConfig(async ({ mode, command }): Promise<UserConfig> => {
11+
const config: UserConfig = {
12+
// https://vitejs.dev/config/shared-options.html#base
13+
base: './',
14+
// Resolver
15+
resolve: {
16+
// https://vitejs.dev/config/shared-options.html#resolve-alias
17+
alias: {
18+
'@': fileURLToPath(new URL('./src', import.meta.url)),
19+
},
2120
},
22-
},
23-
plugins: [
24-
Vue(),
25-
// vite-plugin-checker
26-
// https://github.com/fi3ework/vite-plugin-checker
27-
checker({
28-
typescript: true,
29-
vueTsc: true,
30-
eslint: {
31-
lintCommand: 'eslint', // for example, lint .ts & .tsx
21+
// https://vitejs.dev/config/#server-options
22+
server: {
23+
fs: {
24+
// Allow serving files from one level up to the project root
25+
allow: ['..'],
3226
},
33-
}),
34-
],
35-
// Build Options
36-
// https://vitejs.dev/config/#build-options
37-
build: {
38-
outDir: 'docs',
39-
rollupOptions: {
40-
output: {
41-
manualChunks: {
42-
vue: ['vue', 'vue-demi'],
43-
lodash: ['lodash'],
44-
codemirror: [
45-
'codemirror',
46-
'@codemirror/autocomplete',
47-
'@codemirror/commands',
48-
'@codemirror/language',
49-
'@codemirror/lint',
50-
'@codemirror/search',
51-
'@codemirror/state',
52-
'@codemirror/view',
53-
// Add the following as needed.
54-
'@codemirror/lang-html',
55-
'@codemirror/lang-javascript',
56-
'@codemirror/lang-markdown',
57-
],
58-
eslint: ['eslint-linter-browserify'],
27+
},
28+
plugins: [
29+
Vue(),
30+
// vite-plugin-checker
31+
// https://github.com/fi3ework/vite-plugin-checker
32+
checker({
33+
typescript: true,
34+
vueTsc: true,
35+
eslint: {
36+
lintCommand: 'eslint',
37+
},
38+
}),
39+
],
40+
optimizeDeps: {
41+
exclude: ['vue-demi'],
42+
},
43+
// Build Options
44+
// https://vitejs.dev/config/#build-options
45+
build: {
46+
outDir: 'docs',
47+
rollupOptions: {
48+
output: {
49+
manualChunks: {
50+
vue: ['vue', 'vue-demi'],
51+
lodash: ['lodash'],
52+
codemirror: [
53+
'codemirror',
54+
'@codemirror/autocomplete',
55+
'@codemirror/commands',
56+
'@codemirror/language',
57+
'@codemirror/lint',
58+
'@codemirror/search',
59+
'@codemirror/state',
60+
'@codemirror/view',
61+
// Add the following as needed.
62+
'@codemirror/lang-html',
63+
'@codemirror/lang-javascript',
64+
'@codemirror/lang-markdown',
65+
],
66+
eslint: ['eslint-linter-browserify'],
67+
},
5968
},
6069
},
70+
// Minify option
71+
target: 'esnext',
72+
minify: 'esbuild',
73+
},
74+
esbuild: {
75+
// drop: command === 'serve' ? [] : ['console'],
6176
},
62-
target: 'esnext',
63-
},
77+
};
78+
79+
// Write meta data.
80+
fs.writeFileSync(
81+
fileURLToPath(new URL('./src/Meta.ts', import.meta.url)),
82+
`import type MetaInterface from '@/interfaces/MetaInterface';
83+
84+
// This file is auto-generated by the build system.
85+
const meta: MetaInterface = {
86+
version: '${pkg.version}',
87+
date: '${new Date().toISOString()}',
6488
};
89+
export default meta;
90+
`
91+
);
6592

66-
// Export vite config
67-
export default defineConfig(config);
93+
// Export vite config
94+
return config;
95+
});

0 commit comments

Comments
 (0)