Search code examples
angularreleasepublish

Push in release Angular2 Quick Step application


I'm new with Angular2. I've follow the quick start guide and create my application.

Now, I'm ready to push in production on my server. But I've many and many files.

I've found this SO : How to bundle an Angular app for production

But I do not understand. If I make a npm build, dist folder do not exist but no error happen.

If I try something with Gulp, I do not understand to. like here : http://blog.scottlogic.com/2015/12/24/creating-an-angular-2-build.html

If there an easy way to create release files in a folder and push it online without many many commands before?


Solution

  • I've found a solution : migrate to Angular CLI.

    This link help me a lot : http://www.codingpedia.org/ama/fast-faster-angular-cli-how-i-converted-my-angular-project-to-use-angular-cli

    I add some lines in my .angular.cli.json for styles and scripts. I put my app parameters :

    "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets",
            "app/api",
            "favicon.ico"
          ],
          "index": "index.html",
          "main": "main.ts",
          "polyfills": "polyfills.ts",
          "test": "test.ts",
          "tsconfig": "tsconfig.app.json",
          "testTsconfig": "tsconfig.spec.json",
          "prefix": "app",
          "styles": [
            "styles.scss",
            "../src/assets/vendors/bootstrap/dist/css/bootstrap.min.css",
            "../node_modules/font-awesome/css/font-awesome.css",
            "../src/assets/vendors/iCheck/skins/flat/green.css",
            "../src/assets/build/css/custom.min.css"
          ],
          "scripts": [
              "../src/assets/vendors/jquery/dist/jquery.min.js",
              "../src/assets/vendors/bootstrap/dist/js/bootstrap.min.js",
              "../src/assets/vendors/datatables.net/js/jquery.dataTables.min.js",
              "../src/assets/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js",
              "../src/assets/vendors/datatables.net-buttons/js/dataTables.buttons.min.js",
              "../src/assets/vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js",
              "../src/assets/vendors/datatables.net-buttons/js/buttons.flash.min.js",
              "../src/assets/vendors/datatables.net-buttons/js/buttons.html5.min.js",
              "../src/assets/vendors/datatables.net-buttons/js/buttons.print.min.js",
              "../src/assets/vendors/jszip/dist/jszip.min.js",
              "../src/assets/vendors/pdfmake/build/pdfmake.min.js",
              "../src/assets/vendors/pdfmake/build/vfs_fonts.js"
            ],
          "environmentSource": "environments/environment.ts",
          "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts"
          }
        }
      ]
    

    I have to optimise this but it's working now.