├── .github └── ISSUE_TEMPLATE │ └── bug_report.md ├── .gitignore ├── LICENSE ├── README.md ├── __tests__ ├── build.spec.js ├── createProject.helper.js └── testSetup.helper.js ├── generator └── index.js ├── index.js ├── jest.config.js ├── package.json ├── prompts.js └── yarn.lock /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Environment (please complete the following information):** 24 | - vue-cli-plugin-tauri version : 25 | - other vue plugins used: 26 | - (if possible) link to your repo: 27 | - output from `npx tauri info`/`yarn tauri info`: 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | __tests__/temp_projects -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Tauri 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-cli-plugin-tauri 2 | 3 | > [Tauri](https://tauri.app) is a toolkit for creating smaller, faster, and more secure desktops applications with a web frontend. This plugin configures Tauri to work in your Vue CLI project. 4 | 5 | ## Deprecation Notice 6 | 7 | Just like [Vue CLI](https://cli.vuejs.org/) itself, this plugin is now **deprecated** and won't receive any updates anymore. Please migrate to [`@tauri-apps/cli`](https://www.npmjs.com/package/@tauri-apps/cli). 8 | 9 | ## Installation 10 | 11 | Please visit the [documentation website](https://tauri.app) or our [discord server](https://discord.gg/tauri) if you have any problems. 12 | 13 | ### General Prerequisites: 14 | 15 | - NodeJS/npm 16 | - Vue CLI (`yarn global add @vue/cli` / `npm i -g @vue/cli`) 17 | - [Rust/Cargo](https://www.rust-lang.org/) 18 | 19 | ### Detailed Prerequisite Installation Instructions: 20 | 21 | https://tauri.app/v1/guides/getting-started/prerequisites 22 | 23 | ### Steps: 24 | 25 | 1. Create a Vue CLI project (or cd into an existing one) 26 | 27 | ```bash 28 | vue create my-tauri-app 29 | cd my-tauri-app 30 | ``` 31 | 32 | 2. Install Vue CLI Plugin Tauri 33 | 34 | ```bash 35 | vue add tauri 36 | ``` 37 | 38 | 3. Run commands 39 | 40 | With Yarn: 41 | 42 | ```bash 43 | # Start dev server with HMR 44 | yarn tauri:serve 45 | # Build executable 46 | yarn tauri:build 47 | ``` 48 | 49 | With npm: 50 | 51 | ```bash 52 | # Start dev server with HMR 53 | npm run tauri:serve 54 | # Build executable 55 | npm run tauri:build 56 | ``` 57 | -------------------------------------------------------------------------------- /__tests__/build.spec.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const fs = require('fs') 3 | 4 | jest.setTimeout(240000) 5 | const create = require('./createProject.helper') 6 | 7 | describe('tauri:build', () => { 8 | it('Should build a tauri app', async () => { 9 | const project = await create('build') 10 | const configPath = path.resolve(project.dir, 'src-tauri/tauri.conf.json') 11 | const config = fs.readFileSync(configPath).toString() 12 | fs.writeFileSync(configPath, config.replace('com.tauri.dev', 'com.tauri.test')) 13 | 14 | await project.run('vue-cli-service tauri:build') 15 | // Web code is built 16 | expect(project.has('src-tauri/target/webpack_dist/index.html')).toBe(true) 17 | // Tauri app is built 18 | expect(project.has('src-tauri/target/release/app')).toBe(true) 19 | expect( 20 | project.has( 21 | 'src-tauri/target/release/bundle/appimage/app_0.1.0_amd64.AppImage' 22 | ) 23 | ).toBe(true) 24 | expect( 25 | project.has('src-tauri/target/release/bundle/deb/app_0.1.0_amd64.deb') 26 | ).toBe(true) 27 | }) 28 | }) 29 | -------------------------------------------------------------------------------- /__tests__/createProject.helper.js: -------------------------------------------------------------------------------- 1 | const create = require('@vue/cli-test-utils/createTestProject') 2 | const { defaultPreset } = require('@vue/cli/lib/options') 3 | const path = require('path') 4 | 5 | module.exports = (projectName) => { 6 | const preset = { ...defaultPreset } 7 | preset.plugins['vue-cli-plugin-tauri'] = { 8 | appName: 'app', 9 | windowTitle: 'app' 10 | } 11 | delete preset.plugins['@vue/cli-plugin-eslint'] 12 | 13 | return create( 14 | projectName, 15 | preset, 16 | path.join(process.cwd(), '/__tests__/temp_projects') 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /__tests__/testSetup.helper.js: -------------------------------------------------------------------------------- 1 | const lnk = require('lnk') 2 | const fs = require('fs') 3 | // Prevent full and unnecessary project creation 4 | process.env.VUE_CLI_TEST = true 5 | // Link ./ to node_modules/vcp-tauri so that require.resolve(vcp-tauri) returns ./ 6 | if (!fs.existsSync('./node_modules/vue-cli-plugin-tauri')) { 7 | try { 8 | lnk.sync(['./'], './node_modules/vue-cli-plugin-tauri') 9 | } catch (err) { 10 | if (err.code !== 'EEXIST') console.error(err) 11 | } 12 | } 13 | 14 | try { 15 | fs.mkdirSync('./__tests__/temp_projects') 16 | } catch (err) { 17 | if (err.code !== 'EEXIST') console.error(err) 18 | } 19 | -------------------------------------------------------------------------------- /generator/index.js: -------------------------------------------------------------------------------- 1 | const cli = require('@tauri-apps/cli') 2 | 3 | module.exports = async (api, options) => { 4 | cli.run([ 5 | 'init', 6 | '--directory', api.resolve('.'), 7 | '--app-name', options.appName, 8 | '--window-title', options.windowTitle, 9 | '--dist-dir', 'Set automatically by Vue CLI plugin', 10 | '--dev-path', 'Set automatically by Vue CLI plugin' 11 | ]) 12 | 13 | api.extendPackage({ 14 | scripts: { 15 | 'tauri:serve': 'vue-cli-service tauri:serve', 16 | 'tauri:build': 'vue-cli-service tauri:build' 17 | } 18 | }) 19 | } 20 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 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.tauri ? 5 | options.pluginOptions.tauri : 6 | {} 7 | 8 | api.chainWebpack((cfg) => { 9 | if (process.env.TAURI_SERVE || process.env.TAURI_BUILD) { 10 | // Set IS_TAURI 11 | if (cfg.plugins.has('define')) { 12 | cfg.plugin('define').tap((args) => { 13 | args[0]['process.env'].IS_TAURI = true 14 | return args 15 | }) 16 | } else { 17 | cfg.plugin('define').use(DefinePlugin, [{ 18 | 'process.env': { 19 | IS_TAURI: true 20 | } 21 | }]) 22 | } 23 | 24 | // Apply custom config from user 25 | if (pluginOptions.chainWebpack) { 26 | pluginOptions.chainWebpack(cfg) 27 | } 28 | } 29 | }) 30 | 31 | api.registerCommand( 32 | 'tauri:serve', { 33 | description: 'Starts Tauri in development mode', 34 | usage: 'vue-cli-service tauri:serve' 35 | }, 36 | async () => { 37 | const cli = require('@tauri-apps/cli') 38 | 39 | const server = await api.service.run('serve') 40 | const config = { 41 | build: { 42 | devPath: server.url 43 | } 44 | } 45 | 46 | cli.run(['dev', '--config', JSON.stringify(config)]) 47 | } 48 | ) 49 | 50 | api.registerCommand( 51 | 'tauri:build', { 52 | description: 'Builds the Tauri application', 53 | usage: 'vue-cli-service tauri:build [options]', 54 | options: { 55 | '--skip-bundle': 'skip bundling the frontend application', 56 | '--verbose': 'enables verbose logging', 57 | '--debug': 'build with the debug flag', 58 | '--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', 59 | '--bundle': 'set which applications bundle to package, e.g. "appimage,deb" or "app,dmg". Defaults to all bundles for the current platform', 60 | } 61 | }, 62 | async (args) => { 63 | const cli = require('@tauri-apps/cli') 64 | const { 65 | error 66 | } = require('@vue/cli-shared-utils') 67 | 68 | if (!args['skip-bundle']) { 69 | try { 70 | await api.service.run('build', { 71 | dest: 'src-tauri/target/webpack_dist' 72 | }) 73 | } catch (e) { 74 | error( 75 | 'Vue CLI build failed. Please resolve any issues with your build and try again.' 76 | ) 77 | process.exit(1) 78 | } 79 | } 80 | 81 | const config = { 82 | build: { 83 | distDir: './target/webpack_dist' 84 | } 85 | } 86 | const cliArgs = ['build', '--config', JSON.stringify(config)] 87 | if (args.v || args.verbose) { 88 | cliArgs.push('--verbose') 89 | } 90 | if (args.d || args.debug) { 91 | cliArgs.push('--debug') 92 | } 93 | if (args.t || args.target) { 94 | cliArgs.push('--target') 95 | cliArgs.push(args.t ? args.t : args.target) 96 | } 97 | if (args.b || args.bundle) { 98 | cliArgs.push('--bundle') 99 | cliArgs.push(args.b ? args.b : args.bundle) 100 | } 101 | await cli.run(cliArgs) 102 | } 103 | ) 104 | } 105 | 106 | module.exports.defaultModes = { 107 | 'tauri:build': 'production', 108 | 'tauri:serve': 'development' 109 | } 110 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | setupFiles: ['/__tests__/testSetup.helper.js'], 4 | testPathIgnorePatterns: [ 5 | '/node_modules/', 6 | '/__tests__/temp_projects/', 7 | '.*.helper.js' 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-cli-plugin-tauri", 3 | "version": "1.0.0", 4 | "description": "A Vue CLI plugin for rigging Tauri", 5 | "main": "index.js", 6 | "author": "Noah Klayman ", 7 | "license": "MIT", 8 | "private": false, 9 | "scripts": { 10 | "test": "jest", 11 | "pretest": "rimraf __tests__/temp_projects/*" 12 | }, 13 | "dependencies": { 14 | "@tauri-apps/cli": "^1.0.3", 15 | "@vue/cli-shared-utils": "^4.1.1" 16 | }, 17 | "devDependencies": { 18 | "@vue/cli": "^4.1.1", 19 | "@vue/cli-plugin-babel": "^4.1.1", 20 | "@vue/cli-service": "^4.1.1", 21 | "@vue/cli-test-utils": "^4.1.1", 22 | "jest": "^24.9.0", 23 | "lnk": "^1.1.0", 24 | "rimraf": "^3.0.0", 25 | "vue": "^2.6.11", 26 | "vue-template-compiler": "^2.6.12" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /prompts.js: -------------------------------------------------------------------------------- 1 | module.exports = pkg => [ 2 | { 3 | type: 'input', 4 | name: 'appName', 5 | message: 'What should the app name be?', 6 | validate: input => !!input, 7 | default: pkg.name 8 | }, 9 | { 10 | type: 'input', 11 | name: 'windowTitle', 12 | message: 'What should the window title be?', 13 | validate: input => !!input, 14 | default: 'Tauri App' 15 | } 16 | ] 17 | --------------------------------------------------------------------------------