Skip to content
This repository was archived by the owner on Nov 9, 2023. It is now read-only.

Commit 4be8ed8

Browse files
committed
fix(index): set IS_TAURI in serve and build
before, it was only set in builds in addition, apply custom webpack config in serve
1 parent 2486c88 commit 4be8ed8

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

index.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)