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

Commit b00b828

Browse files
committed
chore(package): upgrade tauri
1 parent 7cceade commit b00b828

File tree

4 files changed

+1189
-62
lines changed

4 files changed

+1189
-62
lines changed

generator/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
const execa = require('execa')
22
const { error } = require('@vue/cli-shared-utils')
33
const fs = require('fs-extra')
4+
const init = require('tauri/api/init')
45

56
module.exports = async api => {
67
await execa('cargo', ['tauri-cli', '--version']).catch(() => {
78
// TODO: provide better error
89
error('Tauri CLI crate not installed')
910
process.exit(1)
1011
})
11-
require('tauri/bin/tauri-init')
12+
13+
init({
14+
directory: api.resolve('.')
15+
})
16+
1217
api.extendPackage({
1318
scripts: {
1419
'tauri:serve': 'vue-cli-service tauri:serve',

index.js

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
1-
module.exports = api => {
1+
module.exports = (api, options) => {
2+
// If plugin options are provided in vue.config.js, those will be used. Otherwise it is empty object
3+
const pluginOptions =
4+
options.pluginOptions && options.pluginOptions.electronBuilder
5+
? options.pluginOptions.electronBuilder
6+
: {}
7+
8+
api.chainWebpack(cfg => {
9+
if (process.env.TAURI_BUILD) {
10+
// Setup require for no-server mode
11+
const TauriRequirePlugin = require('@tauri-apps/tauri-webpack/plugins/tauri-require')
12+
.plugin
13+
cfg.plugin('tauri-require').use(TauriRequirePlugin)
14+
15+
// Set IS_TAURI
16+
if (cfg.plugins.has('define')) {
17+
cfg.plugin('define').tap(args => {
18+
args[0]['process.env'].IS_TAURI = true
19+
return args
20+
})
21+
} else {
22+
cfg.plugin('define').use(DefinePlugin, [
23+
{
24+
'process.env': { IS_TAURI: true }
25+
}
26+
])
27+
}
28+
29+
// Apply custom config from user
30+
if (pluginOptions.chainWebpack) {
31+
pluginOptions.chainWebpack(cfg)
32+
}
33+
}
34+
})
35+
236
api.registerCommand(
337
'tauri:serve',
438
{
@@ -7,25 +41,15 @@ module.exports = api => {
741
usage: 'todo'
842
},
943
async () => {
10-
const { tauriDir } = require('tauri/helpers/app-paths')
11-
const Runner = require('tauri/runner')
12-
const tauri = new Runner()
44+
const dev = require('tauri/api/dev')
1345

1446
const server = await api.service.run('serve')
1547

16-
const tauriConfig = require('tauri/helpers/tauri-config')({
17-
ctx: {
18-
debug: true
19-
},
48+
return dev({
2049
build: {
2150
devPath: server.url
2251
}
2352
})
24-
25-
require('tauri/generator').generate(tauriConfig.tauri)
26-
require('tauri/entry').generate(tauriDir, tauriConfig)
27-
28-
tauri.run(tauriConfig)
2953
}
3054
)
3155

@@ -37,33 +61,31 @@ module.exports = api => {
3761
usage: 'todo'
3862
},
3963
async args => {
40-
const { tauriDir } = require('tauri/helpers/app-paths')
41-
const Runner = require('tauri/runner')
42-
const tauri = new Runner()
43-
const tauriConfig = require('tauri/helpers/tauri-config')({
44-
ctx: {
45-
debug: args.debug,
46-
modeDir: tauriDir
47-
},
64+
const build = require('tauri/api/build')
65+
66+
// Use custom config for webpack
67+
process.env.TAURI_BUILD = true
68+
// Set publicPath so that scripts are properly imported
69+
options.publicPath = './'
70+
71+
if (!args.skipBundle) {
72+
try {
73+
await api.service.run('build', {
74+
dest: 'dist_tauri/bundled'
75+
})
76+
} catch (e) {
77+
error(
78+
'Vue CLI build failed. Please resolve any issues with your build and try again.'
79+
)
80+
process.exit(1)
81+
}
82+
}
83+
84+
build({
4885
build: {
4986
distDir: 'dist_tauri/bundled'
5087
}
5188
})
52-
require('tauri/generator').generate(tauriConfig.tauri)
53-
require('tauri/entry').generate(tauriDir, tauriConfig)
54-
55-
try {
56-
await api.service.run('build', {
57-
dest: 'dist_tauri/bundled'
58-
})
59-
} catch (e) {
60-
error(
61-
'Vue CLI build failed. Please resolve any issues with your build and try again.'
62-
)
63-
process.exit(1)
64-
}
65-
66-
tauri.build(tauriConfig)
6789
}
6890
)
6991
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"license": "MIT",
88
"private": false,
99
"dependencies": {
10+
"@tauri-apps/tauri-webpack": "^0.1.4",
1011
"@vue/cli-shared-utils": "^4.1.1",
1112
"execa": "^3.4.0",
12-
"tauri": "^0.1.9"
13+
"tauri": "^0.2.0"
1314
}
1415
}

0 commit comments

Comments
 (0)