11module . exports = ( api , options ) => {
22 // If plugin options are provided in vue.config.js, those will be used. Otherwise it is empty object
33 const pluginOptions =
4- options . pluginOptions && options . pluginOptions . tauri
5- ? options . pluginOptions . tauri
6- : { }
4+ options . pluginOptions && options . pluginOptions . tauri ?
5+ options . pluginOptions . tauri :
6+ { }
77
88 api . chainWebpack ( ( cfg ) => {
99 if ( process . env . TAURI_SERVE || process . env . TAURI_BUILD ) {
@@ -14,11 +14,11 @@ module.exports = (api, options) => {
1414 return args
1515 } )
1616 } else {
17- cfg . plugin ( 'define' ) . use ( DefinePlugin , [
18- {
19- 'process.env' : { IS_TAURI : true }
17+ cfg . plugin ( 'define' ) . use ( DefinePlugin , [ {
18+ 'process.env' : {
19+ IS_TAURI : true
2020 }
21- ] )
21+ } ] )
2222 }
2323
2424 // Apply custom config from user
@@ -29,47 +29,51 @@ module.exports = (api, options) => {
2929 } )
3030
3131 api . registerCommand (
32- 'tauri:serve' ,
33- {
34- // TODO: fill in meta
35- description : 'todo' ,
36- usage : 'todo'
32+ 'tauri:serve' , {
33+ description : 'Starts Tauri in development mode' ,
34+ usage : 'vue-cli-service tauri:serve'
3735 } ,
3836 async ( ) => {
39- const { dev } = require ( '@tauri-apps/cli/dist/api /cli' )
37+ const cli = require ( '@tauri-apps/cli' )
4038
4139 // Use custom config for webpack
4240 process . env . TAURI_SERVE = true
4341
4442 const server = await api . service . run ( 'serve' )
45-
46- return dev ( {
47- config : {
48- build : {
49- devPath : server . url
50- }
43+ const config = {
44+ build : {
45+ devPath : server . url
5146 }
52- } )
47+ }
48+
49+ cli . run ( [ 'dev' , '--config' , JSON . stringify ( config ) ] )
5350 }
5451 )
5552
5653 api . registerCommand (
57- 'tauri:build' ,
58- {
59- // TODO: fill in meta
60- description : 'todo' ,
61- usage : 'todo'
54+ 'tauri:build' , {
55+ description : 'Builds the Tauri application' ,
56+ usage : 'vue-cli-service tauri:build [options]' ,
57+ options : {
58+ '--skip-bundle' : 'skip bundling the frontend application' ,
59+ '--verbose' : 'enables verbose logging' ,
60+ '--debug' : 'build with the debug flag' ,
61+ '--target' : 'target triple to build against. It must be one of the values outputted by `$rustc --print target-list` or `universal-apple-darwin` for an universal macOS application. note that compiling an universal macOS application requires both `aarch64-apple-darwin` and `x86_64-apple-darwin` targets to be installed' ,
62+ '--bundle' : 'set which applications bundle to package, e.g. "appimage,deb" or "app,dmg". Defaults to all bundles for the current platform' ,
63+ }
6264 } ,
6365 async ( args ) => {
64- const { build } = require ( '@tauri-apps/cli/dist/api/cli' )
65- const { error } = require ( '@vue/cli-shared-utils' )
66+ const cli = require ( '@tauri-apps/cli' )
67+ const {
68+ error
69+ } = require ( '@vue/cli-shared-utils' )
6670
6771 // Use custom config for webpack
6872 process . env . TAURI_BUILD = true
6973 // Set publicPath so that scripts are properly imported
7074 options . publicPath = ''
7175
72- if ( ! args . skipBundle ) {
76+ if ( ! args [ 'skip-bundle' ] ) {
7377 try {
7478 await api . service . run ( 'build' , {
7579 dest : 'src-tauri/target/webpack_dist'
@@ -82,17 +86,27 @@ module.exports = (api, options) => {
8286 }
8387 }
8488
85- build ( {
86- config : {
87- build : {
88- distDir : './target/webpack_dist'
89- }
90- } ,
91- verbose : args . v || args . verbose || false ,
92- debug : args . d || args . debug || false ,
93- target : args . t || args . target || false ,
94- bundle : args . b || args . bundle || false
95- } )
89+ const config = {
90+ build : {
91+ distDir : './target/webpack_dist'
92+ }
93+ }
94+ const cliArgs = [ 'build' , '--config' , JSON . stringify ( config ) ]
95+ if ( args . v || args . verbose ) {
96+ cliArgs . push ( '--verbose' )
97+ }
98+ if ( args . d || args . debug ) {
99+ cliArgs . push ( '--debug' )
100+ }
101+ if ( args . t || args . target ) {
102+ cliArgs . push ( '--target' )
103+ cliArgs . push ( args . t )
104+ }
105+ if ( args . b || args . bundle ) {
106+ cliArgs . push ( '--bundle' )
107+ cliArgs . push ( args . b )
108+ }
109+ cli . run ( cliArgs )
96110 }
97111 )
98112}
0 commit comments