-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
executable file
·51 lines (49 loc) · 1.42 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
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import postcssNesting from 'postcss-nesting';
import { resolve } from 'path';
import handlebars from 'vite-plugin-handlebars';
import { getMiCss } from './utils/get-css.mjs';
import { config as pkgConfig } from './package.json';
// import fs from 'fs';
// https://vitejs.dev/config/
export default async ({ command }) => {
let miCss;
if (command === 'build') {
// weird workaround to get the embed file to be the main output with proper paths
// fs.copyFileSync(resolve(__dirname, 'templates/embed.html'), 'embed.html');
// fs.copyFileSync(resolve(__dirname, 'templates/simple-table.html'), 'simple-table.html');
} else {
miCss = await getMiCss();
}
return defineConfig({
plugins: [
svelte(),
handlebars({
partialDirectory: resolve(__dirname, 'partials'),
context: {
title: pkgConfig.projectName + '-dev',
miCss: miCss
},
}),
],
css: {
postcss: {
plugins: [postcssNesting],
},
},
build: {
chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
assetFileNames: "assets/[name][extname]",
chunkFileNames: "assets/[name].js",
entryFileNames: "assets/[name].js"
},
input: {
embed: resolve(__dirname, 'partials/embed.html')
},
},
},
});
};