This is an alternative project structure for the Ionic Framework demonstrated with the ionic tabs starter.
To use this starter create a new project folder (e.g. 'myApp') for your app and clone this repository into it.
$ cd mkdir myApp
$ git clone https://github.com/flavordaaave/ionic_better_structure.gitThen run npm and bower to get all needed dependencies:
$ npm install
$ bower installAll working files are underneath the 'src' folder trying to follow the angular styleguide created by johnpapa.
/src
/app
/images
/lib
/styles
index.html
Everything is set up to serve from this src folder using
$ ionic serveThis project comes with a before_build hook to run the 'gulp build' task before actually building the app with cordova. The 'gulp build' task concatenates, minifies and copies the files into the 'www' folder from where cordova is loading the files. So you can just use the standard ionic build commands:
$ ionic platform add ios
$ ionic build ios
$ ionic emulate iosA bunch of useful gulp tasks have been copied from the HotTowel yeoman generator created by johnpapa and modified to work with ionic.
-
gulp helpDisplays all of the available gulp tasks.
-
gulp vetPerforms static code analysis on all javascript files. Runs jshint and jscs.
-
gulp vet --verboseDisplays all files affected and extended information about the code analysis.
-
gulp testRuns all unit tests using karma runner & jasmine with phantomjs. Depends on vet task, for code analysis.
-
gulp cleanRemove all files from the build and temp folders
-
gulp clean-imagesRemove all images from the build folder
-
gulp clean-codeRemove all javascript and html from the build folder
-
gulp clean-fontsRemove all fonts from the build folder
-
gulp clean-stylesRemove all styles from the temp and build folders
-
gulp fontsCopy the ionic fonts from source to the build folder
-
gulp imagesCopy all images from source to the build folder
-
gulp stylesCompile less files to CSS and copy to the build folder
-
gulp wiredepLooks up all bower components' main files and JavaScript source code, then adds them to the
index.html. The.bowerrcfile also runs this as a postinstall task wheneverbower installis run.NOTE: wiredep will only grab the bower dependencies that are listed in you bower.json file. Use the
--saveflag when installing dependencies via bower to add them to automatically add them to you bower.json file.
-
gulp templatecacheCreate an Angular module that adds all HTML templates to Angular's $templateCache. This pre-fetches all HTML templates saving XHR calls for the HTML.
-
gulp templatecache --verboseDisplays all files affected by the task.
-
ionic serveYou can us the standard ionic serve task here.
-
gulp optimizeOptimize all javascript and styles, move to a build folder, and inject them into the new index.html
-
gulp buildCopies the ionic fonts, copies images and runs
gulp optimizeto build the production code to the build folder.
NOTE: This project contains a before_build hook for cordova which so that the gulp build task is run automatically when building with cordova build [platfrom] or ionic build [platfrom]