-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
61 lines (54 loc) · 1.53 KB
/
vite.config.js
File metadata and controls
61 lines (54 loc) · 1.53 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
import { defineConfig, splitVendorChunkPlugin } from "vite";
import liveReload from "vite-plugin-live-reload";
import path from "path";
import fs from "fs";
export default ({ mode }) => {
const currentFolder = path.dirname(__filename).split(path.sep).pop();
if (mode === "development") {
fs.writeFileSync(`${__dirname}/inc/dev.mode`, "");
} else {
try {
fs.unlinkSync(`${__dirname}/inc/dev.mode`);
} catch {}
}
return defineConfig({
css: {
devSourcemap: true,
},
plugins: [
liveReload([
// edit live reload paths according to your source code
// for example: __dirname + "/(app|config|views)/**/*.php",
// using this for our example:
__dirname + "/**/*.php",
]),
splitVendorChunkPlugin(),
],
base: `/${mode === 'development' ? '' : 'dist/'}`,
build: {
// output dir for production build
outDir: "./dist",
emptyOutDir: true,
// emit manifest so PHP can find the hashed files
manifest: true,
// our entry
rollupOptions: {
input: path.resolve(__dirname, "js/main.js"),
output: {
entryFileNames: `assets/[name]-add.js`,
chunkFileNames: `assets/[name].js`,
manualChunks: {},
assetFileNames: (assetInfo) => {
if (assetInfo.name.includes('css')) return `assets/${assetInfo.name}`;
return `img/${assetInfo.name}`;
}
}
},
},
server: {
cors: true,
strictPort: true,
port: 3000,
},
});
};