• This repository has been archived on 01/May/2020
  • Stars
    star
    612
  • Rank 73,287 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

App Build Scripts for Ionic Projects

npm version Circle CI

DISCLAIMER: NO LONGER MAINTAINED

Oh, hello there! Ionic App Scripts is a tool tied specifically to version 3.x of Ionic Framework. Since the release of version 4.0 of Ionic Framework, we are no longer using Ionic App Scripts for building in Ionic Framework. Version 3 of Ionic Framework is no longer actively maintained by us. For more information on which versions are active, see our support policy. Due to this, we are no longer maintaining Ionic App Scripts and we recommend developers update their apps to the latest framework release. This provides several new features, bug fixes, performance improvements, as well as up to date tooling for Ionic apps. For more details on how to upgrade, check out our migration guide.

Ionic App Scripts

Helper scripts to get Ionic apps up and running quickly (minus the config overload).

To get the latest @ionic/app-scripts, please run:

npm install @ionic/app-scripts@latest --save-dev

Config Defaults

Out of the box, Ionic starters have been preconfigured with great defaults for building fast apps, including:

  • Multi-core processing tasks in parallel for faster builds
  • In-memory file transpiling and bundling
  • Transpiling source code to ES5 JavaScript
  • Ahead of Time (AoT) template compiling
  • Just in Time (JiT) template compiling
  • Template inlining for JiT builds
  • Bundling modules for faster runtime execution
  • Treeshaking unused components and dead-code removal
  • Generating CSS from bundled component Sass files
  • Autoprefixing vendor CSS prefixes
  • Minifying JavaScript files
  • Compressing CSS files
  • Copying src static assets to www
  • Linting source files
  • Watching source files for live-reloading

Just the bullet list above is a little overwhelming, and each task requires quite a bit of development time just to get started. Ionic App Script's intention is to make it easier to complete common tasks so developers can focus on building their app, rather than building build scripts.

Note that the Ionic Framework's source is made up of modules and can be packaged by any bundler or build process. However, this project's goal is provide simple scripts to make building Ionic apps easier, while also allowing developers to further configure their build process.

npm Scripts

Instead of depending on external task runners, Ionic App Scripts now prefers being executed from npm scripts. Ionic's npm scripts come preconfigured in the project's package.json file. For example, this is the default setup for npm scripts in each starter:

  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },

To run the build script found in the package.json scripts property, execute:

npm run build

Environments

You can use Node style process.env.MY_VAR syntax directly in your typescript and when the application is bundled it'll be replaced with the following order of precedence:

  • If the variable exists in the process environment it will be replaced with that value.
  • If the variable is not defined in the process environment it will be read from a .env.dev file for dev builds or .env.prod file for prod builds which are located in the root of the app
  • If the variable is not defined in either place it will be undefined

In order to take advantage of this apps will need a src/declarations.d.ts file with the following declaration:

declare var process: { env: { [key: string]: string | undefined; } };

Note: This declaration may conflict if @types/node is installed in your project. See #3541.

Custom Configuration

In many cases, the defaults which Ionic provides cover most of the scenarios required by developers; however, Ionic App Scripts does provide multiple ways to configure and override the defaults for each of the various tasks. Note that Ionic will always apply its defaults for any property that was not provided by custom configuration.

Default Config Files

package.json Config

Ionic projects use the package.json file for configuration. There's a handy config property which can be used. Below is an example of setting a custom config file using the config property in a project's package.json.

  "config": {
    "ionic_cleancss": "./config/cleancss.config.js"
  },

Command-line Flags

Remember how we're actually running ionic-app-scripts from the scripts property of a project's package.json file? Well we can also add command-line flags to each script, or make new scripts with these custom flags. For example:

  "scripts": {
    "build": "ionic-app-scripts build --webpack ./config/webpack.dev.config.js",
    "minify": "ionic-app-scripts minify --cleancss ./config/cleancss.config.js",
  },

The same command-line flags can be also applied to npm run commands too, such as:

npm run build --webpack ./config/webpack.dev.config.js

Overriding Config Files

Config File package.json Config Cmd-line Flag
CleanCss ionic_cleancss --cleancss or -e
Copy ionic_copy --copy or -y
Generator ionic_generator --generator or -g
NGC ionic_ngc --ngc or -n
Sass ionic_sass --sass or -s
TSLint ionic_tslint --tslint or -i
UglifyJS ionic_uglifyjs --uglifyjs or -u
Watch ionic_watch --watch
Webpack ionic_webpack --webpack or -w

Overriding Config Values

Config Values package.json Config Cmd-line Flag Defaults Details
root directory ionic_root_dir --rootDir process.cwd() The directory path of the Ionic app
src directory ionic_src_dir --srcDir src The directory holding the Ionic src code
www directory ionic_www_dir --wwwDir www The deployable directory containing everything needed to run the app
build directory ionic_build_dir --buildDir build The build process uses this directory to store generated files, etc
temp directory ionic_tmp_dir --tmpDir .tmp Temporary directory for writing files for debugging and various build tasks
ionic-angular directory ionic_angular_dir --ionicAngularDir ionic-angular ionic-angular directory
ionic-angular entry point ionic_angular_entry_point --ionicAngularEntryPoint index.js entry point file for ionic-angular
source map type ionic_source_map_type --sourceMapType source-map Chooses the webpack devtool option. eval and source-map are supported
generate source map ionic_generate_source_map --generateSourceMap true Determines whether to generate a source map or not
tsconfig path ionic_ts_config --tsconfig {{rootDir}}/tsconfig.json absolute path to tsconfig.json
app entry point ionic_app_entry_point --appEntryPoint {{srcDir}}/app/main.ts absolute path to app's entrypoint bootstrap file
app ng module path ionic_app_ng_module_path --appNgModulePath {{srcDir}}/app/app.module.ts absolute path to app's primary NgModule
app ng module class ionic_app_ng_module_class --appNgModuleClass AppModule Exported class name for app's primary NgModule
clean before copy ionic_clean_before_copy --cleanBeforeCopy false clean out existing files before copy task runs
output js file ionic_output_js_file_name --outputJsFileName main.js name of js file generated in buildDir
output css file ionic_output_css_file_name --outputCssFileName main.css name of css file generated in buildDir
bail on lint error ionic_bail_on_lint_error --bailOnLintError null Set to true to make stand-alone lint commands fail with non-zero status code
enable type checking during lint ionic_type_check_on_lint --typeCheckOnLint null Set to true to enable type checking during lint
write AoT files to disk ionic_aot_write_to_disk --aotWriteToDisk null Set to true to write files to disk for debugging
print webpack dependency tree ionic_print_webpack_dependency_tree --printWebpackDependencyTree null Set to true to print out a dependency tree after running Webpack
parse deeplink config ionic_parse_deeplinks --parseDeepLinks true Parses and extracts data from the @IonicPage decorator
convert bundle to ES5 ionic_build_to_es5 --buildToEs5 true Convert bundle to ES5 for production deployments
default watch timeout ionic_start_watch_timeout --startWatchTimeout 3000 Milliseconds controlling the default watch timeout
choose the polyfill ionic_polyfill_name --polyfillName polyfills Change with polyfills.modern or polyfills.ng (all options)[https://github.com/driftyco/ionic/tree/master/scripts/polyfill]
enable linting ionic_enable_lint --enableLint true Set to false for skipping the linting after the build

Ionic Environment Variables

These environment variables are automatically set to Node's process.env property. These variables can be useful from within custom configuration files, such as custom webpack.config.js file.

Environment Variable Description
IONIC_ENV Value can be either prod or dev.
IONIC_ROOT_DIR The absolute path to the project's root directory.
IONIC_SRC_DIR The absolute path to the app's source directory.
IONIC_WWW_DIR The absolute path to the app's public distribution directory.
IONIC_BUILD_DIR The absolute path to the app's bundled js and css files.
IONIC_TMP_DIR Temp directory for debugging generated/optimized code and various build tasks
IONIC_NODE_MODULES_DIR The absolute path to the node_modules directory.
IONIC_ANGULAR_DIR The absolute path to the ionic-angular node_module directory.
IONIC_APP_SCRIPTS_DIR The absolute path to the @ionic/app-scripts node_module directory.
IONIC_SOURCE_MAP_TYPE The Webpack devtool setting. eval and source-map are supported.
IONIC_GENERATE_SOURCE_MAP Determines whether to generate a sourcemap or not.
IONIC_TS_CONFIG The absolute path to the project's tsconfig.json file
IONIC_APP_ENTRY_POINT The absolute path to the project's main.ts entry point file
IONIC_APP_NG_MODULE_PATH The absolute path to app's primary NgModule
IONIC_APP_NG_MODULE_CLASS The exported class name for app's primary NgModule
IONIC_GLOB_UTIL The path to Ionic's glob-util script. Used within configs.
IONIC_CLEAN_BEFORE_COPY Attempt to clean existing directories before copying files.
IONIC_CLOSURE_JAR The absolute path ot the closure compiler jar file
IONIC_OUTPUT_JS_FILE_NAME The file name of the generated javascript file
IONIC_OUTPUT_CSS_FILE_NAME The file name of the generated css file
IONIC_WEBPACK_FACTORY The absolute path to Ionic's webpack-factory script
IONIC_WEBPACK_LOADER The absolute path to Ionic's custom webpack loader
IONIC_BAIL_ON_LINT_ERROR Boolean determining whether to exit with a non-zero status code on error
IONIC_TYPE_CHECK_ON_LINT Boolean determining whether to type check code during lint or not
IONIC_AOT_WRITE_TO_DISK --aotWriteToDisk
IONIC_PRINT_WEBPACK_DEPENDENCY_TREE boolean to print out a dependency tree after running Webpack
IONIC_PARSE_DEEPLINKS boolean to enable parsing the Ionic 3.x deep links API for lazy loading
IONIC_BUILD_TO_ES5 boolean to enable converting bundle to ES5 for production deployments
IONIC_START_WATCH_TIMEOUT Milliseconds controlling the default watch timeout

The process.env.IONIC_ENV environment variable can be used to test whether it is a prod or dev build, which automatically gets set by any command. By default the build and serve tasks produce dev builds (a build that does not include Ahead of Time (AoT) compilation or minification). To force a prod build you should use the --prod command line flag.

process.env.IONIC_ENV environment variable is set to prod for --prod builds, otherwise dev for all other builds.

All Available Tasks

These tasks are available within ionic-app-scripts and can be added to npm scripts or any Node command.

Task Description
build A complete build of the application. It uses development settings by default. Use --prod to create an optimized build
clean Empty the www/build directory.
cleancss Compress the output CSS with CleanCss
copy Run the copy tasks, which by defaults copies the src/assets/ and src/index.html files to www.
lint Run the linter against the source .ts files, using the tslint.json config file at the root.
minify Minifies the output JS bundle and compresses the compiled CSS.
sass Sass compilation of used modules. Bundling must have at least ran once before Sass compilation.
watch Runs watch for dev builds.

Example NPM Script:

  "scripts": {
    "minify": "ionic-app-scripts minify"
  },

Tips

  1. The Webpack devtool setting is driven by the ionic_source_map_type variable. It defaults to source-map for the best quality source map. Developers can enable significantly faster builds by setting ionic_source_map_type to eval.
  2. By default, the lint command does not exit with a non-zero status code on error. To enable this, pass --bailOnLintError true to the command.
"scripts" : {
  ...
  "lint": "ionic-app-scripts lint"
  ...
}
npm run lint --bailOnLintError true

The Stack

Contributing

We welcome any PRs, issues, and feedback! Please be respectful and follow the Code of Conduct.

We use Node 6, and NPM 5 for contributing.

Publish a Nightly Build

  1. Run npm run build to generate the dist directory
  2. Run npm run test to validate the dist works
  3. Tick the package.json version
  4. Run npm run nightly to generate a nightly build on npm

Publish a release

Execute the following steps to publish a release:

  1. Ensure your branch has been merged into master
  2. Run npm run build to generate the dist directory
  3. Run npm run test to validate the dist works
  4. Temporarily tick the package.json version
  5. Run npm run changelog to append the latest additions to the changelog
  6. Manually verify and commit the changelog changes. Often times you'll want to manually add content/instructions
  7. Revert the package.json version to the original version
  8. Run npm version patch to tick the version and generate a git tag
  9. Run npm run github-release to create the github release entry
  10. Run npm publish to publish the package to npm
  11. git push origin master - push changes to master

More Repositories

1

ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
TypeScript
49,820
star
2

ionicons

Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎
TypeScript
17,166
star
3

stencil

A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
TypeScript
11,913
star
4

capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
TypeScript
11,539
star
5

ionic-conference-app

A conference app built with Ionic to demonstrate Ionic
TypeScript
3,543
star
6

ng-cordova

OBSOLETE: Please move to Ionic Native https://github.com/ionic-team/ionic-native
JavaScript
3,499
star
7

ionic-cli

The Ionic command-line interface
TypeScript
1,991
star
8

ionic-angular-cordova-seed

The perfect starting point for an Ionic project
JavaScript
726
star
9

ionic-pwa-toolkit

Build lightning fast Progressive Web Apps with zero config and best practices built-in. Go from zero to production ready with Ionic and Stencil (Web Components).
TypeScript
634
star
10

ionic-plugin-keyboard

Ionic Keyboard Plugin for Cordova
C++
613
star
11

ionic-docs

HTML
581
star
12

ionic-react-conference-app

The Ionic Conference Demo App - Now in React
TypeScript
498
star
13

capacitor-plugins

Official plugins for Capacitor ⚡️
Java
491
star
14

cordova-plugin-ionic-webview

Web View plugin for Cordova, specialized for Ionic apps.
Objective-C
482
star
15

ionic-site

Repo for the ionicframework.com site
JavaScript
453
star
16

capacitor-assets

Local Capacitor icon/splash screen resource generation tool
TypeScript
448
star
17

starters

Starter templates for Ionic apps, used by the Ionic CLI
JavaScript
446
star
18

ionic-app-base

A base starting point for Ionic, with Cordova, Bower, and Gulp.
JavaScript
424
star
19

ionic-ion-tinder-cards

Add Tinder-style card swiping to any app with this simple Ionic Ion.
JavaScript
390
star
20

ionic-storage

Ionic Storage module for Ionic apps
TypeScript
389
star
21

ionic-starter-super

The Ionic 2 Super Starter 🎮
TypeScript
382
star
22

ionic-unit-testing-example

Example of adding unit testing in your Ionic 2.x or greater apps with Karma and Jasmine
TypeScript
378
star
23

ionic-ion-swipe-cards

Swipeable card based layout for Ionic and Angular
JavaScript
354
star
24

ionic-plugin-deeplinks

Handle deeplinks into your Ionic/Cordova apps from Universal Links, App Links, and Custom URL schemes. For those using Ionic 2, there are some nice goodies that make life easier.
Objective-C
332
star
25

stencil-site

Stencil site and documentation source.
TypeScript
318
star
26

graphite

Clean jQuery Mobile theme-pack and theme generator
JavaScript
302
star
27

stencil-component-starter

Minimal starter project for building shareable web components with Stencil https://github.com/ionic-team/stencil
TypeScript
263
star
28

stencil-ds-output-targets

These are output targets that can be added to Stencil for React and Angular.
TypeScript
247
star
29

ionic2-starter-aws

Ionic + AWS MobileHub Starter Project
JavaScript
238
star
30

collide

A powerful javascript animation engine for web and hybrid mobile apps, inspired by Facebook Pop, built by the Ionic team.
JavaScript
234
star
31

ionic-native-google-maps

Google maps plugin for Ionic Native
TypeScript
223
star
32

ionic2-app-base

Template for starting Ionic 2 apps, used by the Ionic CLI
CSS
222
star
33

front-page

An example Hacker News app showcasing what's possible with Ionic
JavaScript
198
star
34

trapeze

The mobile project configuration toolbox. Manage native iOS, Android, Ionic/Capacitor, React Native, and Flutter apps through a simple YAML format.
TypeScript
194
star
35

ionic-v1

The repo for Ionic 1.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
JavaScript
192
star
36

ionic-starter-tabs

A starting project for Ionic using a simple tabbed interface
HTML
161
star
37

ionic-ion-header-shrink

A demo of making a header that shrinks based on the user scrolling (like Facebook's iOS app).
JavaScript
161
star
38

creator-weekly-workshops

Here you can find any code that we use in the Creator Demo Videos
JavaScript
154
star
39

ionifits

Human Resources demo app (Zenefits clone) serving as a reference for enterprise app developers on the Ionic stack.
TypeScript
152
star
40

ionic-example-cordova-camera

An example of how to use the Cordova Camera API
JavaScript
150
star
41

stencil-store

Store is a lightweight shared state library by the StencilJS core team. Implements a simple key/value map that efficiently re-renders components when necessary.
TypeScript
149
star
42

ionic-starter-maps

An Ionic starter project using Google Maps and a side menu
JavaScript
143
star
43

tutorial-photo-gallery-angular

Photo Gallery Tutorial: Ionic Angular and Capacitor
TypeScript
139
star
44

pwa-elements

Quality UI experiences for Web APIs that require custom UI (such as media/camera).
TypeScript
135
star
45

ionic-v3

The repo for Ionic 3.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
TypeScript
129
star
46

ionic-starter-sidemenu

A starting project for Ionic using a side menu with navigation in the content area
JavaScript
126
star
47

native-run

Utility for running native binaries on iOS and Android devices and simulators/emulators
TypeScript
123
star
48

ionic-contrib-frosted-glass

An optional frosted-glass effect for iOS 7 styled Ionic apps.
JavaScript
123
star
49

ionic-heroku-button

A one-click Ionic app template for Heroku
JavaScript
123
star
50

ionic-starter-cardboard

A google cardboard template for Ionic
JavaScript
113
star
51

ionic-pwa-demos

A collection of cool Ionic Progressive Web App demos. PR to add your own!
JavaScript
109
star
52

rollup-plugin-node-polyfills

JavaScript
108
star
53

ionic-vue-conference-app

Ionic Conference app ported to Vue
Vue
104
star
54

ionic-stencil-hn-app

Ionic Stencil HackerNews App
TypeScript
103
star
55

ionic-module-template

A template for building a reusable Angular 2 module for Ionic 2 apps
TypeScript
96
star
56

stencil-state-tunnel

A tool for tunneling state/props down through a component stack.
TypeScript
95
star
57

stencil-redux

TypeScript
95
star
58

ionic-bower

Bower repository for Ionic
JavaScript
93
star
59

ionic-stencil-conference-app

A conference app built with Stencil to demonstrate Ionic
TypeScript
90
star
60

ionic-present

Present Ionic in your town. Share the new way to build mobile apps.
JavaScript
90
star
61

capacitor-remix-templates

Build native iOS, Android, and Web apps with Capacitor and Remix.run 💿
Swift
90
star
62

ionic2-starter-tutorial

This tutorial goes along with the example on Ionic v2 documentation
TypeScript
87
star
63

ionic-starter-salesforce

A starter project for Ionic and Salesforce
JavaScript
85
star
64

cordova-plugin-ionic

Ionic Cordova SDK
TypeScript
78
star
65

ionic-proxy-example

A quick Ionic project showing how to use the proxy server
JavaScript
75
star
66

docs-demo

A demo/kitchen sink for the docs
TypeScript
74
star
67

ionic-contrib-firebase-login

Using Firebase's angularFire and simple login with Ionic
JavaScript
69
star
68

ionic-package-hooks

Cordova hooks that you can run in Ionic Package
JavaScript
69
star
69

stencil-sass

Sass plugin for Stencil
TypeScript
69
star
70

angular-toolkit

Angular Schematics and Builders for `@ionic/angular` apps.
TypeScript
68
star
71

ionic2-starter

An Ionic2 starter project
68
star
72

tutorial-photo-gallery-react

Photo Gallery Tutorial: Ionic React and Capacitor
TypeScript
68
star
73

legacy-ionic-cloud

JavaScript Client for legacy Ionic Cloud services. See Ionic Pro for our new take on the ionic development lifecycle
TypeScript
65
star
74

photo-gallery-tutorial-ionic4

Ionic framework v4 tutorial: Building a Photo Gallery!
TypeScript
64
star
75

ionic-learn

CSS
62
star
76

ionic-ion-frost

A reusable frosted-glass effect for adding this cool iOS effect to your Ionic apps.
JavaScript
62
star
77

create-capacitor-plugin

Create a new Capacitor plugin ⚡️
Mustache
58
star
78

tutorial-photo-gallery-vue

Photo Gallery Tutorial: Ionic Vue and Capacitor
CSS
57
star
79

ionic2-starter-tabs

A starting project for Ionic using a simple tabbed interface
TypeScript
53
star
80

ionic-portals

Portals Javascript Library and Docs
JavaScript
52
star
81

ionic-ion-drawer

A side menu drawer for Ionic apps
JavaScript
51
star
82

tslint-ionic-rules

Common TypeScript lint rules/preferences for Ionic.
TypeScript
50
star
83

stencil-router-v2

TypeScript
45
star
84

ionic-app-lib

The library used for using ionic apps - consumed by the CLI and the GUI
JavaScript
44
star
85

capacitor-starters

A collection of projects to use as a resource for new Capacitor apps
JavaScript
44
star
86

stencil-ds-plugins-demo

This is a demo project using the stencil-ds-plugins.
TypeScript
44
star
87

create-stencil

npm init stencil
TypeScript
43
star
88

ionic-gulp-tasks

Collection of gulp tasks for building Ionic apps
JavaScript
41
star
89

ionic2-starter-sidemenu

A starting project for Ionic with side menu navigation
TypeScript
41
star
90

ionic-code

Ionic code
JavaScript
40
star
91

stencil-ds-react-template

This is an example repo of building plugins.
TypeScript
37
star
92

appflow-build

GitHub Action for triggering Appflow Builds
TypeScript
36
star
93

stencil-inspector

TypeScript
36
star
94

ionic2-deeplinks-demo

A test repo for deep linking in Ionic 2
JavaScript
35
star
95

capacitor-background-runner

C
35
star
96

ionic-ion-ios-buttons

Simple iOS 7 style rounded buttons with CSS
34
star
97

portals-ecommerce-demo

E-commerce Demo App using Ionic Portals
Java
33
star
98

ionic-e2e-example

Example app for Ionic E2E
TypeScript
32
star
99

capacitor-testapp

TypeScript
32
star
100

eas-2021

Conference app for the Ionic Enterprise App Summit 2021.
TypeScript
31
star