https://github.com/appfeel/ionic-plugin-build
Ionic builder plugin
https://github.com/appfeel/ionic-plugin-build
Last synced: about 2 months ago
JSON representation
Ionic builder plugin
- Host: GitHub
- URL: https://github.com/appfeel/ionic-plugin-build
- Owner: appfeel
- Created: 2016-10-25T09:56:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-27T11:16:09.000Z (over 7 years ago)
- Last Synced: 2024-04-14T04:37:55.451Z (about 1 year ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ionic Build plugin
**NOTE:** It requires that all development to be done under `src/` folder, instead of `www/` folder.
This is an Ionic plugin to build source files. It performs the following operations:
- Preprocess `index.html` (see [preprocess](https://www.npmjs.com/package/preprocess))
- Read all `*.html` templates, lint and converts them to minified javascript files, using `$templateCache.put(...)`
- Transforms all `templateUrl: 'path/to/template.html'` into `templateProvider:function($templateCache){return $templateCache.get('path/to/template.html')}`
- Read all `.css` files from `index.html`, minifies and concats them into `all.min.css` (minification is only done when -p flag is set or when -sc flag is set without -p flag)
- In every `.css`, replaces `../fonts/ionicons*` with `${bowerrc path}/ionic/fonts/ionicons*`
- In every `.css`, replaces `../fonts/fontawesomeionicons*` with `${bowerrc path}/components-font-awesome/fonts/fontawesome*`
- In every `.css`, replaces `../img/*` with `img/*`
- Read all `.js` files from `index.html`, lints, annotates, minifies and concats them into `all.min.js` (minification is only done when -p flag is set or when -sc flag is set without -p flag)
- Skips minification in resources under bower modules and already minified ones
- Copies all resources from `src/` to `www/` (images, etc)
- Replaces all scripts in `index.html` between `` and `` with ``
- Replaces all links in `index.html` between `` and `` with ``These tasks are executed every time a `cordova prepare`, `phonegap prepare` or `ionic prepare` is executed.
When the command is `phonegap serve` it copies all files from `src/` to `www/` without modifying them and watch for changes in `src/` directory, so they are immediately populated to corresponding platform.
## Options:
```js
options.help = options.h || options.help; // Help
options.production = options.p || options.prod || options.production; // Production
options.debug = options.d || options.debug; // DEBUG
options.angularDebug = options.ad || options['angular-debug']; // ANGULAR_DEBUG
options.skipLint = options.sl || options['skip-lint']; // Skip lint
options.noFailLint = options.nf || options['no-fail-lint']; // Don't fail on javascript/html errors
options.skipComp = options.sc || options['skip-comp']; // Skip compression
options.verbose = options.vb || options.verb || options.verbose; // Verbose
options.extendedReport = options.xr || options['extended-report']; // Extended hint reports
options.skipAll = options.sa || options['skip-all']; // Extended hint reports
options.preprocessResources = options.ppr || options['preprocess-resources']; // Preprocess resourcesoptions.skipComp = options.production ? options.skipComp : !options.skipComp;
options.env = options.production ? 'production' : 'development';
options.concatResources = options.production;
options.skipHtmlCompression = options.skipHtmlCompression || options.skipComp;
options.skipResCompression = options.skipResCompression || options.skipComp;
options.dest = options.dest || 'build';
global.NODE_ENV = options.env;return {
context: {
NODE_ENV: options.env,
DEBUG: (options.debug && options.production)
|| (!options.debug && !options.production) ? true : undefined,
ANGULAR_DEBUG: (options.angularDebug && options.production)
|| (!options.angularDebug && !options.production) ? true : undefined,
},
};
```Context variables are used to [preprocess](https://www.npmjs.com/package/preprocess) `index.html`.
This options can be used it like this:
```bash
$ cordova prepare browser -p --skip-lint -nf
```## Ionic:
When `cordova serve ...` is executed, this plugin automatically detects it and watch for file changes. The problem with `ionic run browser -l` is that it executes `cordova run browser` untherneath, so no serve can be detected. In this case you can use the `-w` or `-watch` flags:
```
$ ionic run browser -l -w -nf
```