-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
63 lines (61 loc) · 1.96 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
52
53
54
55
56
57
58
59
60
61
62
63
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import preact from "@preact/preset-vite";
// import vue from '@vitejs/plugin-vue';
// Partytown
import path from "path";
import fs from "fs";
import { partytownVite } from "@builder.io/partytown/utils";
import { partytownSnippet } from "@builder.io/partytown/integration";
fs.writeFileSync(
path.join(__dirname, "storage", "app", "public", "partytownSnippet.txt"),
partytownSnippet(),
{
encoding: "utf8",
flag: "w",
}
);
// TODO: resources/js/cp.js and resources/css/cp.css need to get built and NOT included in the frontend bundle
// They currently build but have a hash. It sounds like maybe I'll have to have a separate vite.config (vite.cp.config) and run another vite command in package.json for it. See: https://github.com/vitejs/vite/issues/2039#issuecomment-779356090
// Here's how to output unhashed files?: https://github.com/vitejs/vite/discussions/3278#discussioncomment-721347
// https://laravel.com/docs/9.x/vite
export default defineConfig({
alias: {
react: "preact/compat",
"react-dom": "preact/compat",
},
// esbuild: {
// jsxFactory: "h",
// jsxFragment: "Fragment",
// jsxInject: `import { h, Fragment } from 'preact'`,
// },
plugins: [
laravel([
"resources/css/tailwind.css",
"resources/js/app.js",
// Components
"resources/js/glightbox.js",
"resources/js/Preact/Counter/render.tsx",
// CP
"resources/css/cp.css",
"resources/js/cp.js",
]),
preact(),
// laravel({
// input: "resources/js/app.js",
// publicDirectory: "public", // default
// buildDirectory: "build", // default
// }),
// vue({
// template: {
// transformAssetUrls: {
// base: null,
// includeAbsolute: false,
// },
// },
// }),
partytownVite({
dest: path.join(__dirname, "public", "~partytown"),
}),
],
});