Monaca Docs
Search…
Migrating from Vue
This page demonstrates quick steps to migrate a Vue project into Monaca using the Monaca CLI. After finishing this guide, you are able to run, test, debug and build an app of your Vue project using Monaca.

Prerequisites

    1.
    Before starting the migration process, please make sure to read the key points in order to have a seamless migration.
    2.
    Install the Monaca CLI globally with npm:
    3.
    1
    $ npm install -g monaca
    Copied!

Migration Steps

    1.
    After the Monaca CLI installation, login with your Monaca account:
1
monaca login
Copied!
2. Navigate to your Vue project directory.
1
cd <project dir>
Copied!
3. Then, run monaca init to convert your project to a Monaca project:
1
monaca init
2
...
3
? Are you sure you want to continue initializing this project? Yes
4
? Is it a transpilable project? Yes
5
? Which command do you use to serve the app? vue-cli-service serve
6
? Which command do you use to build the app? vue-cli-service build --dest www --no-clean
7
? Which command do you use to watch the changes from your app? vue-cli-service build --dest www --no-clean --watch
Copied!
4. Add these three new commands to your package.json file:
1
"scripts": {
2
"monaca:preview": "vue-cli-service serve & vue-cli-service build --dest www --no-clean --watch",
3
"monaca:transpile": "vue-cli-service build --dest www --no-clean",
4
"monaca:debug": "vue-cli-service build --dest www --no-clean --watch"
5
}
Copied!
5. Configure the build output directory:
Create a vue.config.js file and add the content below to it so that the index.html file can be served in the file:// protocol.
1
module.exports = {
2
baseUrl: './'
3
}
Copied!

Debugging with the Monaca CLI

Monaca Debugger is an application for testing and debugging your Monaca apps on real devices in real time. When developing Monaca apps on your local PC, all changes you make to the project files reflect in the Monaca Debugger as soon as you save the changes.
Let’s get started with the Monaca Debugger as follows:
    1.
    Install the Monaca Debugger app on your device from Google Play or AppStore.
If you want to install Monaca Debugger on Android emulator, please refer to Monaca Debugger for Android Emulator.
2. Launch the Monaca Debugger app and sign in with your Monaca account. Make sure you are using the same account as for Monaca CLI.
3. Check that the Monaca Debugger and the PC are connected to the same network connection (LAN or Wi-Fi) and disable the firewall of the PC.
4. To pair your device to the PC, navigate to the project directory in the command line and type monaca debug.
1
cd <project dir>
2
monaca debug
Copied!
5. A popup message prompting you to pair the debugger with the PC opens inside the Monaca Debugger.
6. If the pairing is successful, your local project name will appear under Local Projects in Monaca Debugger. However, if the pairing fails, please refer to Fail to pair the Monaca Debugger.
7. To run a project, tap on the project name in the Monaca Debugger (as shown in the above picture).
8. Your project should now be running in the debugger. Go ahead and try out your application. After that, try making some code changes and save them. You should see the changes reflected in the debugger.
To stop debugging and unpair the debugger and the PC, press Ctrl+c.

Building the app

Now that you know how to use the Monaca CLI commands with your Vue project, let’s start building it with the Monaca CLI. For simplicity, we only show how to create a debug build for Android in this guide.

Using only the CLI commands

    1.
    Navigate to the project directory.
    1
    cd <project dir>
    Copied!
    2.
    Start the Android debug build
    1
    monaca remote build android --build-type=debug
    Copied!

Using the CLI Command with GUI

    1.
    Navigate to the project directory.
    1
    cd <project dir>
    Copied!
    2.
    Open the Build Window to start building.
    1
    monaca remote build --browser
    Copied!
    3.
    The debug build is selected by default. Click Start Build.
4. It may take several minutes to complete the build. The following screen will open after the build is successfully completed. Then, you can choose the way to install the app in your device.

Where to go from here

To learn more about Monaca, please refer to the following materials:
Last modified 2mo ago