-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config-for-wp.ts
47 lines (46 loc) · 1.16 KB
/
vite.config-for-wp.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
import { defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
import alias from '@rollup/plugin-alias'
import path from 'path'
import liveReload from 'vite-plugin-live-reload'
import optimizer from 'vite-plugin-optimizer'
import { terser } from 'rollup-plugin-terser'
export default defineConfig({
build: {
emptyOutDir: true,
minify: true,
outDir: path.resolve(__dirname, 'inc/assets/dist'),
watch: {
include: 'inc/**',
exclude:
'js/**, modules/**, node_modules/**, release/**, vendor/**, .git/**, .vscode/**',
},
rollupOptions: {
input: 'inc/assets/src/main.ts', // Optional, defaults to 'src/main.js'.
output: {
assetFileNames: '[ext]/index.[ext]',
entryFileNames: 'index.js',
},
},
},
plugins: [
alias(),
tsconfigPaths(),
liveReload([
__dirname + '/**/*.php',
]),
optimizer({
jquery: 'const $ = window.jQuery; export { $ as default }',
}),
terser({
mangle: {
reserved: ['$'], // 指定 $ 不被改變
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'inc/assets/src'),
},
},
})