-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.pack.config.js
executable file
·84 lines (78 loc) · 2.11 KB
/
vite.pack.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
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
83
84
import vue from "@vitejs/plugin-vue2";
import eslint from "vite-plugin-eslint";
import { splitVendorChunkPlugin } from "vite";
import commonjs from "vite-plugin-commonjs";
import { resolve, normalize, sep, isAbsolute } from "path";
import { defineConfig } from "vite";
import { camelCase } from "lodash";
import { config, dependencies } from "./package.json";
import sanitize from "sanitize-filename";
let outDir = resolve(__dirname, "dist");
if (process.env.BUILD_DEST_DIRECTORY) {
const absolute = isAbsolute(process.env.BUILD_DEST_DIRECTORY);
const arr = process.env.BUILD_DEST_DIRECTORY.split(sep);
outDir = arr
.map((s, index) => {
if ((absolute && index === 0) || s === "." || s === "..") {
return s;
}
return sanitize(s);
})
.join(sep);
if (!absolute) {
outDir = resolve(__dirname, outDir);
}
}
const name = config.packageName;
const externals = ["vue", ...Object.keys(dependencies)];
const externalExcludes = [];
export default defineConfig({
plugins: [
splitVendorChunkPlugin(),
eslint(),
commonjs(),
vue({
isProduction: true,
}),
],
resolve: {
alias: {
"@": resolve(__dirname),
},
},
publicDir: false,
build: {
outDir: normalize(outDir),
commonjsOptions: {
transformMixedEsModules: true,
},
sourcemap: true,
minify: true,
target: "es2015",
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "src/index.js"),
name: "VueQuintable",
// the proper extensions will be added
fileName: (format) => `${name}.${format}.js`,
// formats: ["cjs", "es", "umd"],
},
rollupOptions: {
external: externals.filter((dep) => !externalExcludes.includes(dep)),
// external: [
// "vue",
// "@fortawesome/fontawesome-svg-core",
// "@fortawesome/free-solid-svg-icons",
// "@fortawesome/vue-fontawesome",
// ],
output: {
name: camelCase(name),
assetFileNames: `${name}.[ext]`,
globals: {
vue: "Vue",
},
},
},
},
base: "",
});