mirror of
https://github.com/tauri-apps/vue-cli-plugin-tauri.git
synced 2026-02-04 10:41:18 +01:00
Merge pull request #49 from tauri-apps/feat/rc
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
const { init } = require('@tauri-apps/cli/dist/api/cli')
|
||||
const cli = require('@tauri-apps/cli')
|
||||
|
||||
module.exports = async (api, options) => {
|
||||
init({
|
||||
directory: api.resolve('.'),
|
||||
appName: options.appName,
|
||||
windowTitle: options.windowTitle,
|
||||
distDir: 'Set automatically by Vue CLI plugin',
|
||||
devPath: 'Set automatically by Vue CLI plugin'
|
||||
})
|
||||
cli.run([
|
||||
'init',
|
||||
'--directory', api.resolve('.'),
|
||||
'--app-name', options.appName,
|
||||
'--window-title', options.windowTitle,
|
||||
'--dist-dir', 'Set automatically by Vue CLI plugin',
|
||||
'--dev-path', 'Set automatically by Vue CLI plugin'
|
||||
])
|
||||
|
||||
api.extendPackage({
|
||||
scripts: {
|
||||
|
||||
92
index.js
92
index.js
@@ -1,9 +1,9 @@
|
||||
module.exports = (api, options) => {
|
||||
// If plugin options are provided in vue.config.js, those will be used. Otherwise it is empty object
|
||||
const pluginOptions =
|
||||
options.pluginOptions && options.pluginOptions.tauri
|
||||
? options.pluginOptions.tauri
|
||||
: {}
|
||||
options.pluginOptions && options.pluginOptions.tauri ?
|
||||
options.pluginOptions.tauri :
|
||||
{}
|
||||
|
||||
api.chainWebpack((cfg) => {
|
||||
if (process.env.TAURI_SERVE || process.env.TAURI_BUILD) {
|
||||
@@ -14,11 +14,11 @@ module.exports = (api, options) => {
|
||||
return args
|
||||
})
|
||||
} else {
|
||||
cfg.plugin('define').use(DefinePlugin, [
|
||||
{
|
||||
'process.env': { IS_TAURI: true }
|
||||
cfg.plugin('define').use(DefinePlugin, [{
|
||||
'process.env': {
|
||||
IS_TAURI: true
|
||||
}
|
||||
])
|
||||
}])
|
||||
}
|
||||
|
||||
// Apply custom config from user
|
||||
@@ -29,47 +29,51 @@ module.exports = (api, options) => {
|
||||
})
|
||||
|
||||
api.registerCommand(
|
||||
'tauri:serve',
|
||||
{
|
||||
// TODO: fill in meta
|
||||
description: 'todo',
|
||||
usage: 'todo'
|
||||
'tauri:serve', {
|
||||
description: 'Starts Tauri in development mode',
|
||||
usage: 'vue-cli-service tauri:serve'
|
||||
},
|
||||
async () => {
|
||||
const { dev } = require('@tauri-apps/cli/dist/api/cli')
|
||||
const cli = require('@tauri-apps/cli')
|
||||
|
||||
// Use custom config for webpack
|
||||
process.env.TAURI_SERVE = true
|
||||
|
||||
const server = await api.service.run('serve')
|
||||
|
||||
return dev({
|
||||
config: {
|
||||
build: {
|
||||
devPath: server.url
|
||||
}
|
||||
const config = {
|
||||
build: {
|
||||
devPath: server.url
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
cli.run(['dev', '--config', JSON.stringify(config)])
|
||||
}
|
||||
)
|
||||
|
||||
api.registerCommand(
|
||||
'tauri:build',
|
||||
{
|
||||
// TODO: fill in meta
|
||||
description: 'todo',
|
||||
usage: 'todo'
|
||||
'tauri:build', {
|
||||
description: 'Builds the Tauri application',
|
||||
usage: 'vue-cli-service tauri:build [options]',
|
||||
options: {
|
||||
'--skip-bundle': 'skip bundling the frontend application',
|
||||
'--verbose': 'enables verbose logging',
|
||||
'--debug': 'build with the debug flag',
|
||||
'--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',
|
||||
'--bundle': 'set which applications bundle to package, e.g. "appimage,deb" or "app,dmg". Defaults to all bundles for the current platform',
|
||||
}
|
||||
},
|
||||
async (args) => {
|
||||
const { build } = require('@tauri-apps/cli/dist/api/cli')
|
||||
const { error } = require('@vue/cli-shared-utils')
|
||||
const cli = require('@tauri-apps/cli')
|
||||
const {
|
||||
error
|
||||
} = require('@vue/cli-shared-utils')
|
||||
|
||||
// Use custom config for webpack
|
||||
process.env.TAURI_BUILD = true
|
||||
// Set publicPath so that scripts are properly imported
|
||||
options.publicPath = ''
|
||||
|
||||
if (!args.skipBundle) {
|
||||
if (!args['skip-bundle']) {
|
||||
try {
|
||||
await api.service.run('build', {
|
||||
dest: 'src-tauri/target/webpack_dist'
|
||||
@@ -82,17 +86,27 @@ module.exports = (api, options) => {
|
||||
}
|
||||
}
|
||||
|
||||
build({
|
||||
config: {
|
||||
build: {
|
||||
distDir: './target/webpack_dist'
|
||||
}
|
||||
},
|
||||
verbose: args.v || args.verbose || false,
|
||||
debug: args.d || args.debug || false,
|
||||
target: args.t || args.target || false,
|
||||
bundle: args.b || args.bundle || false
|
||||
})
|
||||
const config = {
|
||||
build: {
|
||||
distDir: './target/webpack_dist'
|
||||
}
|
||||
}
|
||||
const cliArgs = ['build', '--config', JSON.stringify(config)]
|
||||
if (args.v || args.verbose) {
|
||||
cliArgs.push('--verbose')
|
||||
}
|
||||
if (args.d || args.debug) {
|
||||
cliArgs.push('--debug')
|
||||
}
|
||||
if (args.t || args.target) {
|
||||
cliArgs.push('--target')
|
||||
cliArgs.push(args.t)
|
||||
}
|
||||
if (args.b || args.bundle) {
|
||||
cliArgs.push('--bundle')
|
||||
cliArgs.push(args.b)
|
||||
}
|
||||
cli.run(cliArgs)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-cli-plugin-tauri",
|
||||
"version": "1.0.0-beta.6",
|
||||
"version": "1.0.0-rc.0",
|
||||
"description": "A Vue CLI plugin for rigging Tauri",
|
||||
"main": "index.js",
|
||||
"author": "Noah Klayman <noahklayman@gmail.com>",
|
||||
@@ -11,7 +11,7 @@
|
||||
"pretest": "rimraf __tests__/temp_projects/*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/cli": "1.0.0-beta.6",
|
||||
"@tauri-apps/cli": "1.0.0-rc.1",
|
||||
"@vue/cli-shared-utils": "^4.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user