-
Notifications
You must be signed in to change notification settings - Fork 12
/
vite.config.dev.ts
81 lines (78 loc) · 2.94 KB
/
vite.config.dev.ts
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
import { defineConfig, type UserConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import copy from 'rollup-plugin-copy';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'url';
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import { getTheme, getVersion } from "./vite.config";
async function getConfig(): Promise<UserConfig> {
const theme = getTheme();
let version = await getVersion(process.env.buildno);
return {
base: `/_themes/${theme}/`,
plugins: [
vue(),
VueI18nPlugin({
compositionOnly: false,
/* options */
include: [
resolve(dirname(fileURLToPath(import.meta.url)), `udata_front/theme/${theme}/assets/js/locales/**`),
resolve(dirname(fileURLToPath(import.meta.url)), `udata_front/theme/gouvfr/datagouv-components/src/locales/**`),
],
}),
copy({
targets: [
{ src: `udata_front/theme/${theme}/assets/img`, dest: `udata_front/theme/${theme}/static/` },
{ src: "node_modules/leaflet/dist/leaflet.js", dest: `udata_front/theme/${theme}/static/js/` },
{ src: "node_modules/leaflet/dist/leaflet.css", dest: `udata_front/theme/${theme}/static/js/` },
{
src: "node_modules/es-module-shims/dist/es-module-shims.js",
dest: `udata_front/theme/${theme}/static/js/`,
rename: `es-module-shims.${version}.js`,
},
{
src: "node_modules/vue/dist/vue.esm-browser.js",
dest: `udata_front/theme/${theme}/static/js/`,
rename: `vue.esm-browser.prod.${version}.js`,
},
{
src: "node_modules/vue-content-loader/dist/vue-content-loader.es.js",
dest: `udata_front/theme/${theme}/static/js/`,
rename: `vue-content-loader.es.${version}.js`,
},
],
hook: 'writeBundle'
}),
],
envDir: "udata_front/theme/gouvfr/datagouv-components",
build: {
minify: false,
cssCodeSplit: false,
rollupOptions: {
input: [
`udata_front/theme/${theme}/assets/js/index.ts`,
`udata_front/theme/${theme}/assets/js/admin.ts`,
`udata_front/theme/${theme}/assets/less/style.less`,
],
preserveEntrySignatures: 'exports-only',
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ['vue', 'vue-content-loader'],
output: {
dir: `./udata_front/theme/${theme}/static/`,
entryFileNames: `js/[name].${version}.js`,
chunkFileNames: `js/[name].${version}.js`,
assetFileNames: `assets/[name].[ext]`,
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
vue: 'Vue',
"vue-content-loader": "ContentLoader"
}
}
}
}
};
}
// https://vitejs.dev/config/
export default defineConfig(getConfig());