-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvite.config.js
74 lines (72 loc) · 1.69 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
64
65
66
67
68
69
70
71
72
73
74
import { defineConfig } from "vite";
import liveReload from 'vite-plugin-live-reload';
import tailwindcss from "tailwindcss";
import autoprefixer from "autoprefixer";
import postcssNesting from "postcss-nesting";
import sassGlobImports from 'vite-plugin-sass-glob-import';
import glob from "glob";
import path from "path";
import fs from "fs";
const themePath = '/wp-content/themes/themrishvite';
const assets = process.env.NODE_ENV === 'development' ? '/' : '/dist/';
export default defineConfig ( {
plugins: [
liveReload( __dirname + '/**/*.php' ),
sassGlobImports(),
],
root: '',
base: process.env.NODE_ENV === 'development' ? './' : '/dist/',
build: {
outDir: path.resolve( __dirname, './dist' ),
emptyOutDir: true,
manifest: true,
target: 'es2018',
rollupOptions: {
input: {
main: path.resolve( __dirname + '/main.js' )
},
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: ( { name } ) => {
if ( /\.( gif|jpeg|jpg|png|svg|webp| )$/.test( name ?? '' ) ) {
return 'assets/images/[name].[ext]';
}
if ( /\.css$/.test( name ?? '' ) ) {
return 'assets/css/[name].[ext]';
}
if ( /\.js$/.test( name ?? '' ) ) {
return 'assets/js/[name].[ext]';
}
return 'assets/[name].[ext]';
}
},
},
assetsInlineLimit: 0,
minify: false,
write: true,
},
server: {
cors: true,
strictPort: true,
port: 3000,
https: false,
hmr: {
host: 'localhost'
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: `$base-dir: '` + themePath + assets + `';`,
},
},
postcss: {
plugins: [
postcssNesting,
tailwindcss,
autoprefixer,
],
}
},
} );