Skip to content

Commit

Permalink
[ember] update ember ergonomics to not require any manual setup
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcsapo committed Oct 29, 2018
1 parent 1de2180 commit 18b14ea
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 50 deletions.
38 changes: 4 additions & 34 deletions docs/src/pages/basics/guide-ember/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,50 +37,20 @@ npm init

Then add the following NPM script to your package json in order to start the storybook later in this guide:

> In order for your storybook to run properly be sure to be either run `ember serve` or `ember build` before running any storybook commands.
> In order for your storybook to run properly be sure to be either run `ember serve` or `ember build` before running any storybook commands. Running `ember serve` before storybook will enable live reloading.
```json
{
"scripts": {
"storybook": "start-storybook -p 9001 -s dist"
"build-storybook": "ember build & build-storybook -p 9001 -s dist",
"storybook": "ember serve & start-storybook -p 9001 -s dist"
}
}
```

## Setup environment

### Adding preview-head.html

In order for storybook to register your ember application you must add the following file to `.storybook/preview-head.html`

> These scripts may not contain everything you need, a good point of reference is to look at what is in the head tag in your applications `dist/index.html` file when you build.
```
<meta name="{ember-app-name}/config/environment" content="%7B%22modulePrefix%22%3A%22{ember-app-name}%22%2C%22environment%22%3A%22test%22%2C%22rootURL%22%3A%22/%22%2C%22locationType%22%3A%22auto%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3A%7B%22Date%22%3Afalse%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22{ember-app-name}%22%2C%22version%22%3A%224.0.0-alpha.23+4f61a2fb%22%7D%7D" />
<link integrity="" rel="stylesheet" href="./assets/vendor.css">
<link integrity="" rel="stylesheet" href="./assets/{ember-app-name}.css">
<script src="./assets/vendor.js"></script>
<script>
runningTests = true;
</script>
<script src="./assets/{ember-app-name}.js"></script>
```

> Adding the runningTests script is extremely important don't forget to add this as it will result in your application binding multiple times.
Substitute `ember-app-name` with the name of your ember application.

> This is found by going to `package.json` and referencing the name field
### Adding .env

A file named `.env` is needed in the root directory with the following contents:

```
STORYBOOK_NAME={ember-app-name}
```
Your environment will be preconfigured using `ember-cli-storybook`. This will add a `preview-head.html`, a `.env` and make sure that your environment is configured to work with live reload.

## Create the config file

Expand Down
3 changes: 1 addition & 2 deletions examples/ember-cli/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
STORYBOOK_EXAMPLE_APP=true
STORYBOOK_NAME=ember-example
STORYBOOK_NAME=ember-example
2 changes: 2 additions & 0 deletions examples/ember-cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ build
.DS_Store
npm-debug.log
tmp
.env
.storybook/preview-head.html
10 changes: 0 additions & 10 deletions examples/ember-cli/.storybook/preview-head.html

This file was deleted.

3 changes: 2 additions & 1 deletion examples/ember-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "ember build",
"build-storybook": "yarn build && cp -r public/* dist && build-storybook -s dist",
"dev": "ember serve",
"storybook": "yarn build && start-storybook -p 9009 -s dist, public"
"storybook": "start-storybook -p 9009 -s dist, public"
},
"devDependencies": {
"@babel/core": "^7.1.2",
Expand All @@ -33,6 +33,7 @@
"ember-cli-htmlbars-inline-precompile": "^1.0.5",
"ember-cli-inject-live-reload": "^2.0.1",
"ember-cli-shims": "^1.2.0",
"ember-cli-storybook": "*",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^2.0.0",
"ember-load-initializers": "^1.1.0",
Expand Down
41 changes: 38 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,12 @@
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.38.tgz#c1be40aa933723c608820a99a373a16d215a1ca2"
integrity sha512-F/v7t1LwS4vnXuPooJQGBRKRGIoxWUTmA4VHfqjOccFsNDThD5bfUNpITive6s352O7o384wcpEaDV8rHCehDA==

"@types/jest@^23.3.1", "@types/jest@^23.3.8":
"@types/jest@^23.3.1":
version "23.3.7"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.7.tgz#77f9a4332ccf8db680a31818ade3ee454c831a79"
integrity sha512-N0p6mHrS0RHC3A9hHN4QH1RM2fGSb2E8rt6ONEK5xKSnyKtn/JAhr1VritkCn6cdyDBephVB80THqJGWzK8FAw==

"@types/jest@^23.3.8":
version "23.3.8"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.8.tgz#56b07c0c3d7c8a6c47abb4f785cab648c6eafd01"
integrity sha512-OKDxB/7woaQfUKkj+7+Zo3PmAxAYAy+SNwOwFhnYAc8JTaPhGOv8SC6QQg5D9+Giprhx/DzoKbJIpV9799VV0g==
Expand Down Expand Up @@ -3090,7 +3095,19 @@ [email protected]:
postcss "^7.0.2"
postcss-value-parser "^3.2.3"

autoprefixer@^9.1.5, autoprefixer@^9.3.1:
autoprefixer@^9.1.5:
version "9.2.1"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.2.1.tgz#1f2f1179ceed4711b7ab064dbd5c3f9e83d9dc62"
integrity sha512-qlK4GnZk8OXLK+8kBn9ttfzu2PkhRe8kVYoWcc9HsrZEMWiBkQuRYdXyJg9cIIKxfMzhh6UbvlJ1CsstMIzxwA==
dependencies:
browserslist "^4.2.1"
caniuse-lite "^1.0.30000892"
normalize-range "^0.1.2"
num2fraction "^1.2.2"
postcss "^7.0.5"
postcss-value-parser "^3.3.1"

autoprefixer@^9.3.1:
version "9.3.1"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.3.1.tgz#71b622174de2b783d5fd99f9ad617b7a3c78443e"
integrity sha512-DY9gOh8z3tnCbJ13JIWaeQsoYncTGdsrgCceBaQSIL4nvdrLxgbRSBPevg2XbX7u4QCSfLheSJEEIUUSlkbx6Q==
Expand Down Expand Up @@ -8177,6 +8194,14 @@ ember-cli-sri@^2.1.0:
dependencies:
broccoli-sri-hash "^2.1.0"

ember-cli-storybook@*:
version "0.0.0"
resolved "https://registry.yarnpkg.com/ember-cli-storybook/-/ember-cli-storybook-0.0.0.tgz#4cf9049740402175db920a5b20f0c6c970556515"
integrity sha512-B6Czq/9KRtM3rMjQmDiBeHDm7ysOrWUdEoE6wfOEr/YJK3j9KaPISHJNjDIA/U7dJf85b4F2LpvwEXY58Z8r+Q==
dependencies:
cheerio "^1.0.0-rc.2"
ember-cli-babel "^7.1.2"

ember-cli-string-utils@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ember-cli-string-utils/-/ember-cli-string-utils-1.1.0.tgz#39b677fc2805f55173735376fcef278eaa4452a1"
Expand Down Expand Up @@ -18363,7 +18388,17 @@ react-treebeard@^3.1.0:
shallowequal "^1.1.0"
velocity-react "^1.4.1"

"react@^15.6.2 || ^16.0", react@^16.6.0:
"react@^15.6.2 || ^16.0":
version "16.5.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42"
integrity sha512-FDCSVd3DjVTmbEAjUNX6FgfAmQ+ypJfHUsqUJOYNCBUp1h8lqmtC+0mXJ+JjsWx4KAVTkk1vKd1hLQPvEviSuw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
schedule "^0.5.0"

react@^16.6.0:
version "16.6.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.6.0.tgz#b34761cfaf3e30f5508bc732fb4736730b7da246"
integrity sha512-zJPnx/jKtuOEXCbQ9BKaxDMxR0001/hzxXwYxG8septeyYGfsgAei6NgfbVgOhbY1WOP2o3VPs/E9HaN+9hV3Q==
Expand Down

0 comments on commit 18b14ea

Please sign in to comment.