@@ -6,21 +6,7 @@ module.exports = (api, options) => {
6
6
: { }
7
7
8
8
api . chainWebpack ( cfg => {
9
- if ( process . env . TAURI_BUILD ) {
10
- // Setup require for no-server mode
11
- const tauriConfig = require ( 'tauri/dist/helpers/tauri-config' ) ( {
12
- build : {
13
- // Have to be empty strings
14
- distDir : '' ,
15
- devPath : ''
16
- }
17
- } )
18
- if ( ! tauriConfig . tauri . embeddedServer . active ) {
19
- const TauriRequirePlugin = require ( '@tauri-apps/tauri-webpack/plugins/tauri-require' )
20
- . plugin
21
- cfg . plugin ( 'tauri-require' ) . use ( TauriRequirePlugin )
22
- }
23
-
9
+ if ( process . env . TAURI_SERVE || process . env . TAURI_BUILD ) {
24
10
// Set IS_TAURI
25
11
if ( cfg . plugins . has ( 'define' ) ) {
26
12
cfg . plugin ( 'define' ) . tap ( args => {
@@ -40,6 +26,22 @@ module.exports = (api, options) => {
40
26
pluginOptions . chainWebpack ( cfg )
41
27
}
42
28
}
29
+
30
+ if ( process . env . TAURI_BUILD ) {
31
+ // Setup require for no-server mode
32
+ const tauriConfig = require ( 'tauri/dist/helpers/tauri-config' ) ( {
33
+ build : {
34
+ // Have to be empty strings
35
+ distDir : '' ,
36
+ devPath : ''
37
+ }
38
+ } )
39
+ if ( ! tauriConfig . tauri . embeddedServer . active ) {
40
+ const TauriRequirePlugin = require ( '@tauri-apps/tauri-webpack/plugins/tauri-require' )
41
+ . plugin
42
+ cfg . plugin ( 'tauri-require' ) . use ( TauriRequirePlugin )
43
+ }
44
+ }
43
45
} )
44
46
45
47
api . registerCommand (
@@ -52,6 +54,9 @@ module.exports = (api, options) => {
52
54
async ( ) => {
53
55
const dev = require ( 'tauri/dist/api/dev' )
54
56
57
+ // Use custom config for webpack
58
+ process . env . TAURI_SERVE = true
59
+
55
60
const server = await api . service . run ( 'serve' )
56
61
57
62
return dev ( {
0 commit comments