-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathvite.config.ts
54 lines (49 loc) · 1.29 KB
/
vite.config.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
import { defineConfig } from 'vite';
import RubyPlugin from "vite-plugin-ruby"
import FullReload from "vite-plugin-full-reload"
import path from 'path';
import fs from 'fs'
import vue from '@vitejs/plugin-vue2'
const isProd = process.env.NODE_ENV === "production" || process.env.RAILS_ENV === "production"
console.log("WS-HOST: ", process.env.VITE_WSS_HOST)
const items = fs.readdirSync("app/javascript")
const directories = items.filter(item => fs.lstatSync(path.join("app/javascript", item)).isDirectory())
const aliasesFromJavascriptRoot = {}
directories.forEach(directory => {
aliasesFromJavascriptRoot[directory] = path.resolve(__dirname, "app/javascript", directory)
})
// https://vitejs.dev/config/
export default defineConfig({
server: {
hmr: {
host: process.env.VITE_WSS_HOST,
clientPort: 443,
protocol: "wss",
},
},
resolve: {
alias: {
...aliasesFromJavascriptRoot,
vue: 'vue/dist/vue.esm.js'
},
},
plugins: [
RubyPlugin(),
vue(),
FullReload(["config/routes.rb", "app/views/**/*", "app/controllers/**/*"], {
delay: 200,
}),
],
build: {
emptyOutDir: !isProd,
sourcemap: true,
rollupOptions: {
output: {
globals: {
jquery: 'window.$',
$: 'window.$',
}
}
}
}
})