Skip to content

Commit

Permalink
feat: run sync command before building
Browse files Browse the repository at this point in the history
  • Loading branch information
yooouuri committed Mar 30, 2023
1 parent 6cd8213 commit f2f7c16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import esbuild from 'rollup-plugin-esbuild'
export default [
{
input: 'src/index.ts',
external: ['@capacitor/cli/dist/tasks/run', '@capacitor/cli/dist/tasks/build', '@capacitor/cli/dist/config', 'inquirer'],
external: ['@capacitor/cli/dist/tasks/run', '@capacitor/cli/dist/tasks/build', '@capacitor/cli/dist/config', '@capacitor/cli/dist/tasks/sync', 'inquirer'],
output: {
format: 'cjs',
file: `dist/index.js`,
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { runCommand } from '@capacitor/cli/dist/tasks/run'
// @ts-ignore
import { buildCommand } from '@capacitor/cli/dist/tasks/build'
// @ts-ignore
import { syncCommand } from '@capacitor/cli/dist/tasks/sync'
// @ts-ignore
import { loadConfig } from '@capacitor/cli/dist/config'
import inquirer from 'inquirer'

Expand Down Expand Up @@ -52,6 +54,10 @@ export function viteCapacitorPlugin(capacitorConfig?: CapacitorPluginConfig): Pl
},
async closeBundle() {
if (command === 'build') {
// deployment option is set default to false:
// see: https://capacitorjs.com/docs/v2/cli/sync#sync
await syncCommand(config, platform, false)

await buildCommand(config, platform, capacitorConfig?.buildOptions ?? {})
}
}
Expand Down

0 comments on commit f2f7c16

Please sign in to comment.