-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.mjs
67 lines (60 loc) · 1.94 KB
/
vite.config.mjs
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
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite';
import { resolve } from 'node:path'
import pkg from './package.json'
import typescript from '@rollup/plugin-typescript';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
const NAME = pkg.name;
const VERSION = pkg.version;
const banner = `/*!
* ${NAME} v${VERSION}
* (c) ${new Date().getFullYear()} Jenesius
* @license MIT
*/`
const srcFolder = 'src';
export default defineConfig({
plugins: [
{
...typescript({ tsconfig: resolve(srcFolder, "tsconfig.json"), }),
apply: 'build'
},
cssInjectedByJsPlugin({
injectCodeFunction: function injectCodeCustomRunTimeFunction(cssCode, options) {
try {
if (!document) return;
const elementStyle = document.createElement('style');
// SET ALL ATTRIBUTES
for (const attribute in options.attributes) {
elementStyle.setAttribute(attribute, options.attributes[attribute]);
}
elementStyle.appendChild(document.createTextNode(cssCode));
document.head.prepend(elementStyle);
} catch (e) {
console.error('vite-plugin-css-injected-by-js', e);
}
}
}),
vue(),
],
build: {
outDir: resolve( "dist"),
lib: {
entry: resolve(__dirname, srcFolder, "index.ts"),
name: "JenesiusVueForm",
formats: [`cjs`, 'umd', 'es'],
fileName(format) {
return [NAME, format, 'js'].join('.');
}
},
rollupOptions: {
external: ["vue"],
output: {
globals: {
vue: 'Vue',
},
sourcemap: true,
banner
}
},
}
})