Welcome to Ember-CLI 101 workshop hosted by San Diego Ember.
Pre-event setup instructions
- Install Git
- Install Node.js
- Setup NPM for non-sudo installation
- The easiest way to do this is by checking out this awesome shell script that will do it for you
- NPM is the node package manager. It will automatically be installed when you install node.
- NPM installs packages locally (within the directory it is invoked in) for per-project modules, or globally for packages you want accessible everywhere.
- However, by default NPM installs global packages in a root-restricted location, requiring SUDO to install. This creates a huge headache. As an alternative, before you install any packages, follow this guide to configure your NPM to install in your home directory without requiring sudo.
- Install Bower:
npm i -g bower
- Install Ember-CLI:
npm i -g ember-cli
- And create a new project named
workshop
:ember new workshop
- Move into the
workshop
directory:cd workshop
Reduce the glue
Web application development can involve a lot of repetition. Attempts to reduce the repetition involved in web development has given rise to a variety of scaffolding tools and best practices. These scaffolding tools are all trying to do the same thing: reduce the amount of work necessary to "get started" by providing a set of "best practices" that are enabled default. These choices include things like:
- Application directory structure
- Generators for common components
- Modularity choices (AMD/node modules/etc)
- Build system
- Asset compilation & minification
- Testing framework and setup
Ember-CLI
Ember-CLI provides choices for all of the aforementioned areas. We'll dive into some of these choices in more detail later but at a high level Ember-CLI builds in:
- A directory structure which we'll explore more later
- Generators for all common components
- ES6 modules transpiled to AMD
- Broccoli build tool for builds. (Fast and extensible with plugin architecture
- Asset minification also via Broccoli
- QUnit for testing
Modules
Modules allow you to divide logical portions of code into smaller, functional pieces and include them as needed. As your application grows, smaller pieces of functional code become easier to manage, support, maintain and test. To learn more about JS Modules, check out jsmodules.io
Naming best practices
- Code
TitleCase
naming of classescamelCase
naming of attributes- use modules, avoid globals
- reusable code → components, mixins, add-ons
- Files
kebab-case-naming.js
- children in subdirectory →
routes/invoices/edit.js
&routes/invoices/new.js