Skip to content

Commit 5d0ec68

Browse files
author
Jen Weber
authored
Proofreading and additions to upgrading guide (#37)
* add a lot to upgrading * proofreading edits and missing links * fix anchor link * remove configurations from the TOC * linting * move stylesheets and minifying out of legacy folder * use headers for watchman info * line break on periods * fix broken links
1 parent ec608c0 commit 5d0ec68

File tree

15 files changed

+353
-313
lines changed

15 files changed

+353
-313
lines changed

guides/advanced-use/configurations.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,63 @@
11
<!-- Should cover at least minification and fingerprinting -->
2+
<!-- Needs intro! -->
3+
4+
### Minifying
5+
6+
Compiled css-files are minified by `broccoli-clean-css` or `broccoli-csso`,
7+
if it is installed locally. You can pass minifer-specific options to them using
8+
the `minifyCSS:options` object in your ember-cli-build. Minification is enabled by
9+
default in the production-env and can be disabled using the `minifyCSS:enabled`
10+
switch.
11+
12+
Similarly, the js-files are minified with `broccoli-uglify-js` in the
13+
production-env by default. You can pass custom options to the minifier via the
14+
`minifyJS:options` object in your ember-cli-build. To enable or disable JS minification
15+
you may supply a boolean value for `minifyJS:enabled`.
16+
17+
For example, to disable minifying of CSS and JS, add in `ember-cli-build.js`:
18+
19+
```js
20+
// ember-cli-build.js
21+
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
22+
23+
module.exports = function(defaults) {
24+
let app = new EmberApp(defaults, {
25+
minifyJS: {
26+
enabled: false
27+
},
28+
minifyCSS: {
29+
enabled: false
30+
}
31+
});
32+
33+
//...
34+
return app.toTree();
35+
};
36+
```
37+
38+
#### Exclude from minification
39+
40+
Some files should be excluded from minification, such as copied-and-pasted third party scripts that are already minified.
41+
42+
To exclude assets from `dist/assets` from being minified, one can pass options for
43+
[broccoli-uglify-sourcemap](https://github.com/ef4/broccoli-uglify-sourcemap) like so:
44+
45+
```js
46+
// ember-cli-build.js
47+
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
48+
49+
module.exports = function(defaults) {
50+
let app = new EmberApp(defaults, {
51+
minifyJS: {
52+
options: {
53+
exclude: ["**/vendor.js"]
54+
}
55+
}
56+
});
57+
58+
//...
59+
return app.toTree();
60+
};
61+
```
62+
63+
This would exclude the resulting `vendor.js` file from being minified.

guides/advanced-use/stylesheets.md

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,124 @@
1-
<!-- Should cover similar topics as ember-cli.com -->
1+
<!-- Needs an intro section and editing -->
2+
3+
Ember CLI supports plain CSS out of the box. You can add your css styles to
4+
`app/styles/app.css` and it will be served at `assets/application-name.css`.
5+
6+
For example, to add bootstrap in your project you need to do the following:
7+
```bash
8+
bower install bootstrap --save
9+
```
10+
11+
In `ember-cli-build.js` add the following:
12+
```js
13+
app.import('bower_components/bootstrap/dist/css/bootstrap.css');
14+
```
15+
it's going to tell [Broccoli](https://github.com/broccolijs/broccoli) that we want
16+
this file to be concatenated with our `vendor.css` file.
17+
18+
To use a CSS preprocessor, you'll need to install the appropriate
19+
[Broccoli](https://github.com/broccolijs/broccoli) plugin. When using a
20+
preprocessor, Broccoli is configured to look for an `app.less`, `app.scss`, `app.sass`,
21+
or `app.styl` manifest file in `app/styles`. This manifest should import any
22+
additional stylesheets.
23+
24+
All your preprocessed stylesheets will be compiled into one file and served at
25+
`assets/application-name.css`.
26+
27+
If you would like to change this behavior, or compile to multiple output
28+
stylesheets, you can adjust the [Output Paths
29+
Configuration](#configuring-output-paths)
30+
31+
#### CSS
32+
33+
To use plain CSS with `app.css`:
34+
35+
* Write your styles in `app.css` and/or organize your CSS into multiple
36+
stylesheet files and import these files with `@import` from within `app.css`.
37+
* [CSS `@import`
38+
statements](https://developer.mozilla.org/en-US/docs/Web/CSS/@import) (e.g.
39+
`@import 'typography.css';`) must be valid CSS, meaning `@import` statements
40+
*must* precede all other rules and so be placed at the *top* of `app.css`.
41+
42+
To process your imports and replace them with the contents of their files,
43+
add in `ember-cli-build.js`:
44+
```js
45+
// ember-cli-build.js
46+
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
47+
48+
module.exports = function(defaults) {
49+
var app = new EmberApp(defaults, {
50+
minifyCSS: {
51+
options: { processImport: true }
52+
}
53+
});
54+
55+
//...
56+
return app.toTree();
57+
};
58+
```
59+
60+
Which will cause the following to happen:
61+
62+
* In the production build, the `@import` statements are replaced with the
63+
contents of their files and the final minified, concatenated single CSS file
64+
is built to `dist/assets/yourappname-FINGERPRINT_GOES_HERE.css`.
65+
* Any individual CSS files are also built and minified into `dist/assets/` in
66+
case you need them as standalone stylesheets.
67+
* Relative pathing gets changed (how to customize?)
68+
69+
Example `app.css` with valid `@import` usage:
70+
71+
```css
72+
/* @imports must appear at top of stylesheet to be valid CSS */
73+
@import 'typography.css';
74+
@import 'forms.css';
75+
76+
/* Any CSS rules must go *after* any @imports */
77+
.first-css-rule {
78+
color: red;
79+
}
80+
...
81+
```
82+
83+
#### CSS Preprocessors
84+
85+
To use one of the following preprocessors, all you need to do is install the appropriate NPM module.
86+
The respective files will be picked up and processed automatically.
87+
88+
#### LESS
89+
90+
To enable [LESS](http://lesscss.org/), you'll need to add
91+
[ember-cli-less](https://github.com/gdub22/ember-cli-less) to
92+
your NPM modules.
93+
94+
```bash
95+
ember install ember-cli-less
96+
```
97+
98+
#### SCSS/SASS
99+
100+
To enable [SCSS/SASS](http://sass-lang.com/), you'll need to
101+
install the [ember-cli-sass](https://github.com/aexmachina/ember-cli-sass) addon
102+
to your project *(defaults to .scss, .sass allowed via configuration)*.
103+
104+
```bash
105+
ember install ember-cli-sass
106+
```
107+
108+
You can configure your project to use .sass in your `ember-cli-build.js`:
109+
110+
```js
111+
// ember-cli-build.js
112+
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
113+
114+
module.exports = function(defaults) {
115+
let app = new EmberApp({
116+
sassOptions: {
117+
extension: 'sass'
118+
}
119+
});
120+
121+
//...
122+
return app.toTree();
123+
};
124+
```

guides/api-documentation/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The API docs for Ember CLI are mainly for addon authors, advanced Ember app developers, and contributors to the CLI itself.
22

3-
## [https://ember-cli.com/api/](https://ember-cli.com/api/)
3+
[https://ember-cli.com/api/](https://ember-cli.com/api/)
44

55
The docs are the main resource for information like build pipeline modifications, addon author APIs, advanced configurations, and more.
66

guides/basic-use/cli-commands.md

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
In their day to day work, most Ember developers use only a small number of CLI commands.
2-
We'll cover them here, along with a quick tutorial of how to use the `--help` option.
1+
In their daily work, most Ember developers use only a small number of CLI commands.
2+
We'll cover the most common commands here, along with a quick tutorial of how to use the `--help` option. The help option reveals all available commands and options, beyond what this guide covers.
33

44
## Using the help command
55

6-
For any of the commands below, you can see all of the options available by using the `--help` flag.
6+
For any CLI commands, you can see all of the options available by using the `--help` flag.
77

8-
For example, `ember --help` will show a list of all available top level commands. Get more detailed help by adding `--help` to the end of any command, like how `ember generate --help` will show a full list of all the types of files you can create using the CLI.
8+
For example, `ember --help` will show a list of all available top level commands. `ember generate --help` will show a full list of all the types of files you can generate using the CLI.
99

1010
The help command is also the best way to see the aliased or shorthand versions of common commands and options. For example, here are some of the most frequently used abbreviations:
1111

@@ -38,7 +38,7 @@ The help command is also the best way to see the aliased or shorthand versions o
3838

3939
<!-- SCREENSHOT -->
4040

41-
## Create an app
41+
## Create a new app
4242

4343
### Format:
4444

@@ -76,7 +76,10 @@ To stop an Ember server, press `control-c`.
7676

7777
`ember serve` takes all of the app's files and turns them into something that can be rendered in the browser. By default, view the app by visiting `http://localhost:4200`. It's a good idea to keep the server running as we work so that we know as soon as we've broken something. The CLI watches the project folders, and will rerender as files change.
7878

79-
### Example
79+
If the local server will not start due to missing dependencies, use
80+
`npm install` or `yarn install` to get going again.
81+
82+
### Example use
8083

8184
By default, apps are served at port `4200`, but if you need to change it for some reason, you could visit your app at `http://localhost:3200` by using this command:
8285

@@ -86,23 +89,24 @@ ember serve --port 3200
8689

8790
### Learn more
8891

89-
<!-- link to quickstart in the guides -->
92+
- [Ember Quickstart Guide](https://guides.emberjs.com/release/getting-started/quick-start/#toc_create-a-new-application) for starting a local server
9093

91-
## Generate app files
94+
## Generate more files
9295

9396
### Format
9497

9598
```bash
96-
ember generate <type of file> <the name to give it>
99+
ember generate <type-of-file> <name-of-your-choice>
97100
```
98101

99102
### What it does
100103

101104
`ember generate` creates new files within your app. For example, you can use it to create components, routes, services, models, and more. For a full list, type `ember generate --help`.
102105

103-
The new files will contain the necessary boilerplate, they will go in the right place, and the CLI will make sure that file naming conventions are followed. For example, components must always have a dash in their names. Creating files by hand is not recommended because mistakes can lead to confusing error messages.
106+
The new files will contain the necessary boilerplate, they will go in the right place, and the CLI will make sure that file naming conventions are followed. For example, components must always have a dash in their names.
107+
To avoid mistakes that are hard to debug, always use the CLI to create files, instead of creating the files by hand.
104108

105-
### Example
109+
### Example use
106110

107111
This command will make a component named `packing-list`. There will be three files created in the app: `packing-list.hbs` which will define what it looks like, `packing-list.js` with JavaScript code to handle user interaction, and an integration test (aka rendering test) file called `packing-list-test.js`.
108112

@@ -112,9 +116,9 @@ ember generate component packing-list
112116

113117
### Learn more
114118

115-
<!-- link to custom blueprints -->
119+
- [Ember Quickstart Guide](https://guides.emberjs.com/release/getting-started/quick-start/#toc_define-a-route) for creating a route
116120

117-
## Installing dependencies
121+
## Installing addons
118122

119123
### Format
120124

@@ -124,23 +128,27 @@ ember install <addon-name>
124128

125129
### What it does
126130

127-
`ember install` is used to install addons within your app. An addon is an npm package that was built for use in an Ember app. Most addons have a name that starts with `ember`. You can find a full list of addons at [EmberObserver.com](https://emberobserver.com). There are addon versions of many popular npm libraries, as well as packages that are unique to Ember. The majority are open source community addons.
131+
`ember install` is used to install addons within your app. An addon is an npm package that was built especially for use in an Ember app. Most addons have a name that starts with `ember`. You can find a full list of addons at [EmberObserver.com](https://emberobserver.com). There are addon versions of many popular npm libraries, as well as packages that are unique to Ember. The majority are open source community addons.
132+
By convention, most addons have `ember` in the name, but not all of them.
128133

129-
To use npm packages directly, see <!-- LINK --> to learn about the options.
134+
To use non-addon npm packages directly, see [the Ember.js Guide](https://guides.emberjs.com/release/addons-and-dependencies/managing-dependencies/)
135+
to dependencies to learn about the options.
130136

131-
### Example
137+
### Example use
132138

133-
Here's an example of adding SASS support to your app using <!-- LINK TO CLI SASS -->. SASS is an alternative to writing plain CSS. This is a popular community-maintained addon.
139+
Here's an example of adding SASS support to your app using [ember-cli-sass](https://github.com/aexmachina/ember-cli-sass). SASS is an alternative to writing plain CSS. This is a popular community-maintained addon.
134140

135141
```bash
136142
ember install ember-cli-sass
137143
```
138144

139145
### Learn more
140146

141-
<!-- Link to options for plain npm packages -->
142-
<!-- Link to writing your own addon -->
143-
<!-- Link to writing your own wrapper -->
147+
- [Ember CLI Guide](../using-addons/) for using and choosing addons
148+
- [The Ember.js Guides](https://guides.emberjs.com/release/addons-and-dependencies/managing-dependencies/) section on Addons and Dependencies
149+
- [Writing addons](../../writing-addons/) to learn how to make your own addon
150+
151+
<!-- Link to writing your own wrapper, once content is done -->
144152

145153
## Testing your app
146154

@@ -152,9 +160,11 @@ ember test [options]
152160

153161
### What it does
154162
<!--alex disable failed-->
155-
`ember test` runs all of the tests found in the `tests` folder of the app. By default, it runs all the tests once and displays the results. We'll see things like syntax errors, linting problems, deprecations, and failed assertions in the command line output. By default, these tests are run in Headless Chrome. What headless means is, we won't see the visual output of the browser, but it's running them in a Chrome environment. This makes the test suite faster. To watch tests in the browser as they run, visit `http://localhost:4200/tests` while the local server is running.
163+
`ember test` runs all of the tests found in the `tests` folder of the app. By default, it runs all the tests once and displays the results. We'll see things like syntax errors, linting problems, deprecations, and failed assertions in the command line output. To instead watch tests in the browser as they run, visit `http://localhost:4200/tests` while the local server is running with `ember serve`.
164+
165+
By default, these tests are run in Headless Chrome. What headless means is, we won't see the visual output of the browser, but it's running them in a Chrome environment. This makes the test suite faster.
156166

157-
### Example
167+
### Example use
158168

159169
To make tests re-run as we change files, we could use the `--server` option:
160170

@@ -163,6 +173,8 @@ ember test --server
163173
```
164174

165175
### Learn more
176+
- [The Ember.js Guides about Testing](https://guides.emberjs.com/release/testing/)
177+
- [The Ember Super Rentals Tutorial](https://guides.emberjs.com/release/tutorial/ember-cli/) which shows step-by-step how to write tests and understand the results
166178

167179
## Building the app for deployment
168180

@@ -174,13 +186,13 @@ ember build [options]
174186

175187
### What it does
176188

177-
`ember build` takes all of your app files and turns them into a bundle that is minified and transpiled into browser-ready JavaScript code, styles, and html. The bundled files go into a directory called `dist`. This bundle is what can be deployed to a server. By default, it uses the `development` environment configuration.
189+
`ember build` takes all of your app files and turns them into a bundle that is minified and transpiled into browser-ready JavaScript code, styles, and html. The bundled files go into a directory called `dist`. This bundle is what can be deployed to a server. By default, the `build` command uses the `development` environment configuration.
178190

179191
Although you can upload the built files to a server yourself, many Ember projects use a community addon called [ember-cli-deploy](https://github.com/ember-cli-deploy/ember-cli-deploy) to get their apps into production. `ember-cli-deploy` has a plugin system to make it easy to deploy to many cloud vendors. Search [EmberObserver for "deploy"](https://emberobserver.com/?query=deploy) to browse available options.
180192

181193
Ember apps can be built with only three environments: development, production, and testing.
182194

183-
### Example
195+
### Example use
184196

185197
This command builds the app using the production configuration, so that means by default, it will use maximum minification for best app performance.
186198

@@ -190,24 +202,7 @@ ember build --environment production
190202

191203
### Learn more
192204

193-
<!-- what to link to here? something about ember-cli-build -->
194-
195-
196-
<!-- link to guides and maybe super rentals -->
197-
198-
199-
<!--
200-
## Table of Contents
201-
Basic use (explain options of each)
202-
- using the "help" commmand
203-
- ember new
204-
- ember server
205-
- ember generate
206-
- ember test
207-
- ember install (incl link to later section on shims for npm packages)
208-
- feature flags & configurations
209-
- Environmental variables
210-
- File tree reference
211-
- addons/dependencies
212-
- Upgrading
213-
-->
205+
- The [Ember.js Super Rentals Tutorial](https://guides.emberjs.com/release/tutorial/deploying/) has a section on deploying
206+
- Search community addons for deployment on [EmberObserver](https://emberobserver.com/?query=deploy)
207+
- Enable feature flags in different environments using the
208+
[environment config](https://guides.emberjs.com/release/configuring-ember/configuring-your-app/)

guides/basic-use/configurations.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- This page is not yet in production. When it is ready, add it to pages.yml -->
2+
13
<!-- The bare minimum explanation of what to do with ember-cli-build.js -->
24

35
<!--

guides/basic-use/deploying.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The use of HTTPS certificates is best practice for web security and professional
132132

133133
Plain old HTTP sites are likely to show your users security warnings and they are vulnerable to man-in-the-middle attacks. HTTPS certificates are available at no cost from many identity and hosting providers. However, even if you have an HTTPS certificate, you will still need a way to redirect any users who visit `http://your-ember-app.com`, for example.
134134

135-
The following is a simple http-to-https redirect using [nginx](). Don't forget to include your ssl keys in your config.
135+
The following is a simple http-to-https redirect using [nginx](https://nginx.org/en/). Don't forget to include your ssl keys in your config.
136136

137137
First, make a production build of your app. The results will be saved in the `dist` directory:
138138

0 commit comments

Comments
 (0)