@@ -6,21 +6,7 @@ module.exports = (api, options) => {
66 : { }
77
88 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 ) {
2410 // Set IS_TAURI
2511 if ( cfg . plugins . has ( 'define' ) ) {
2612 cfg . plugin ( 'define' ) . tap ( args => {
@@ -40,6 +26,22 @@ module.exports = (api, options) => {
4026 pluginOptions . chainWebpack ( cfg )
4127 }
4228 }
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+ }
4345 } )
4446
4547 api . registerCommand (
@@ -52,6 +54,9 @@ module.exports = (api, options) => {
5254 async ( ) => {
5355 const dev = require ( 'tauri/dist/api/dev' )
5456
57+ // Use custom config for webpack
58+ process . env . TAURI_SERVE = true
59+
5560 const server = await api . service . run ( 'serve' )
5661
5762 return dev ( {
0 commit comments