budiodank / notif-app

Create Notification App With Apache Cordova
0 stars 0 forks source link

How to setup a Cordova App using Vue.js with Vue Material Dashboard #3

Open budiodank opened 5 years ago

budiodank commented 5 years ago

Ini adalah tutorial, cara menggabungkan Cordova dengan Vue.js dengan menggunakan Vue Material Dashboard.

  1. First, npm install -g cordova

  2. npm install -g vue-cli

  3. cordova create project-name

  4. vue init webpack project-name

  5. Terminal will ask you “Target directory exists. Continue?” because the project directory already exists because it was created in the previous Cordova step. “Yes” will be the right answer.

  6. Write your project name, and then description, author.

  7. Vue build ? Choose Runtime + Compiler

  8. Install vue-router? (Y/n) . Write "Y" and then enter

  9. Use ESLint to lint your code? (Y/n) . Write "n" and then enter

  10. Set up unit tests (Y/n) . Write "n" and then enter. And Choose "Karma and Mocha"

  11. Setup e2e tests with Nightwatch? (Y/n) . Write "n" and then enter

  12. Should we run npm install for you after the project has been created? (recom mended) (Use arrow keys) . Choose "Yes, use NPM"

  13. And then wait for minutes.

  14. Open "www/index.html". And change

    <html>
    <head>
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
        <link rel="icon" type="image/png" sizes="96x96" href="<%= webpackConfig.output.publicPath %>favicon.png">
        <link rel="stylesheet" type="text/css" href="css/index.css">
    
         <!--  Fonts and icons     -->
        <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
        <link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons">
        <link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
        <title>River Cleaner</title>
    </head>
    <body>
        <div class="app">
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
    </body>
    </html>
  15. So open the config/index.js file and change it in this way:

    build: {
    // Template for index.html
    index: path.resolve(__dirname, '../www/index.html'),
    
    // Paths
    assetsRoot: path.resolve(__dirname, '../www'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '',
    
    productionSourceMap: true,
    
    devtool: '#source-map',
    
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
    
    bundleAnalyzerReport: process.env.npm_config_report
    }
  16. Copy all file vue from vue-material-dashboard in folder src

  17. Move to folder Cordova project in folder src

  18. Open your terminal, and then change directory to your project

  19. npm install

  20. npm audit fix

  21. npm install

  22. cordova platform add android

  23. npm run build

  24. cordova build android

  25. Finish

if you find an error in the font or icon, you add in root index.html:

<!--  Fonts and icons     -->
        <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
        <link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons">
        <link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">

Referensi :

  1. https://medium.com/@valeriocapogna/how-to-setup-a-cordova-app-using-vue-js-8ba1315b9666 [Accessed: September 2019]
  2. https://www.creative-tim.com/templates/vuejs-dashboard [Accessed: September 2019]
uchihakakashi22 commented 5 years ago

That's work!!!

Thanks