-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathvite.config.js
More file actions
75 lines (72 loc) · 2.58 KB
/
vite.config.js
File metadata and controls
75 lines (72 loc) · 2.58 KB
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
// vite.config.js
import path, {resolve} from "path";
import {defineConfig, loadEnv} from "vite";
import vue from "@vitejs/plugin-vue";
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
import { analyzer } from 'vite-bundle-analyzer'
const stripScssMarker = '/* STYLES STRIP IMPORTS MARKER */'
const projectRootDir = path.resolve(__dirname)
export default ({mode}) => {
const env = loadEnv(mode, process.cwd(), "");
return defineConfig({
root: "./",
publicDir: "public",
define: {
"process.env": env,
'__VUE_OPTIONS_API__': false,
},
plugins: [vue(), {
name: 'vite-plugin-strip-css',
transform(src, id) {
if (id.endsWith('.vue') && !id.includes('node_modules') && src.includes('@extend')) {
console.warn(
'You are using @extend in your component. This is likely not working in your styles. Please use mixins instead.',
id.replace(`${projectRootDir}/`, '')
)
}
if (id.includes('lang.scss')) {
const split = src.split(stripScssMarker)
const newSrc = split[split.length - 1]
return {
code: newSrc,
map: null
}
}
}
}, cssInjectedByJsPlugin(), analyzer()],
resolve: {
alias: {
"@": projectRootDir,
"~": projectRootDir,
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "${projectRootDir}/assets/styles/global.scss";${stripScssMarker}`
},
},
},
build: {
lib: {
// src/indext.ts is where we have exported the component(s)
entry: resolve(__dirname, "components/index.js"),
name: "ChatFAQWidget",
// the name of the output files when the build is run
fileName: "chatfaq-widget",
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: [],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
vue: "Vue"
},
},
},
},
});
};