Skip to content

Commit a193e1a

Browse files
committed
Update to Webpack v2 and Yarn (shakacode#336)
- Replaced npm calls to yarn - updated package.json to webpack and all dependencies - updated config files to use webpack2 syntax - updated docs
1 parent fc1262e commit a193e1a

19 files changed

+6222
-5983
lines changed

Procfile.dev

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
rails: REACT_ON_RAILS_ENV=HOT rails s -b 0.0.0.0
88

99
# Run the hot reload server for client development
10-
hot-assets: sh -c 'rm app/assets/webpack/* || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 npm run hot-assets'
10+
hot-assets: sh -c 'rm app/assets/webpack/* || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 yarn run hot-assets'
1111

1212
# Render static client assets
13-
rails-static-client-assets: sh -c 'npm run build:dev:client'
13+
rails-static-client-assets: sh -c 'yarn run build:dev:client'
1414

1515
# Render static client assets. Remove if not server rendering
16-
rails-static-server-assets: sh -c 'npm run build:dev:server'
16+
rails-static-server-assets: sh -c 'yarn run build:dev:server'

Procfile.express

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
# 3. React on Rails does not have a shared_store JS rendering:
1212
# https://github.com/shakacode/react_on_rails/issues/504
1313

14-
express: sh -c 'HOT_PORT=4000 npm start'
14+
express: sh -c 'HOT_PORT=4000 yarn start'

Procfile.hot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
rails: REACT_ON_RAILS_ENV=HOT rails s -b 0.0.0.0
77

88
# Run the hot reload server for client development
9-
hot-assets: sh -c 'rm app/assets/webpack/* || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 npm run hot-assets'
9+
hot-assets: sh -c 'rm app/assets/webpack/* || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 yarn run hot-assets'
1010

1111
# Keep the JS fresh for server rendering. Remove if not server rendering
12-
rails-server-assets: sh -c 'npm run build:dev:server'
12+
rails-server-assets: sh -c 'yarn run build:dev:server'

Procfile.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# in rails_helper.rb.
44

55
# Build client assets, watching for changes.
6-
rails-client-assets: sh -c 'bundle exec rake react_on_rails:locale && npm run build:dev:client'
6+
rails-client-assets: sh -c 'bundle exec rake react_on_rails:locale && yarn run build:dev:client'
77

88
# Build server assets, watching for changes. Remove if not server rendering.
9-
rails-server-assets: sh -c 'npm run build:dev:server'
9+
rails-server-assets: sh -c 'yarn run build:dev:server'

Procfile.static

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
rails: REACT_ON_RAILS_ENV= rails s -b 0.0.0.0
33

44
# Build client assets, watching for changes.
5-
rails-client-assets: rm app/assets/webpack/* || true && bundle exec rake react_on_rails:locale && npm run build:dev:client
5+
rails-client-assets: rm app/assets/webpack/* || true && bundle exec rake react_on_rails:locale && yarn run build:dev:client
66

77
# Build server assets, watching for changes. Remove if not server rendering.
8-
rails-server-assets: npm run build:dev:server
8+
rails-server-assets: yarn run build:dev:server

Procfile.static.trace

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
rails: TRACE_REACT_ON_RAILS=TRUE rails s -b 0.0.0.0
33

44
# Build client assets, watching for changes.
5-
rails-client-assets: bundle exec rake react_on_rails:locale && npm run build:dev:client
5+
rails-client-assets: bundle exec rake react_on_rails:locale && yarn run build:dev:client
66

77
# Build server assets, watching for changes. Remove if not server rendering.
8-
rails-server-assets: npm run build:dev:server
8+
rails-server-assets: yarn run build:dev:server

client/README.md

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,39 @@ It also includes many eslint defaults that the AirBnb eslint does not include.
1818
Running linter:
1919
===========================
2020

21-
Soon to be in gulpfile....but gulp-eslint depends on eslint depends on
21+
Soon to be in gulpfile....but gulp-eslint depends on eslint depends on
2222

2323
```
2424
"eslint-plugin-react": "^2.0.2",
2525
```
2626

27-
So don't use `npm run gulp lint` yet.
27+
So don't use `yarn run gulp lint` yet.
2828

29-
For now:
29+
For now:
3030

3131
bin/lint
32-
32+
3333
Or (from either top level or within `client` directory)
3434

35-
npm run lint
36-
37-
35+
yarn run lint
36+
37+
3838
Updating Node Dependencies
3939
===========================
4040

4141
```
42-
npm install -g npm-check-updates
42+
yarn global add npm-check-updates
4343
```
44-
44+
4545
Then run this to update the dependencies (starting at the top level).
4646

4747
```
4848
# Make sure you are in the top directory, then run:
49-
cd client
50-
rm npm-shrinkwrap.json
51-
npm-check-updates -u
52-
npm install
53-
npm prune
54-
npm shrinkwrap
49+
cd client
50+
ncu -u
51+
yarn upgrade
5552
```
5653

57-
Then confirm that the hot reload server and the rails server both work fine. You
58-
may have to delete `node_modules` and `npm-shrinkwrap.json` and then run `npm
59-
shrinkwrap`.
60-
61-
Note: `npm prune` is required before running `npm shrinkwrap` to remove dependencies that are no longer needed after doing updates.
62-
63-
6454
Adding Node Modules
6555
=====================================
6656
Suppose you want to add a dependency to "module_name"....
@@ -72,9 +62,5 @@ Before you do so, consider:
7262

7363
```bash
7464
cd client
75-
npm install --save module_name@version
76-
# or
77-
# npm install --save_dev module_name@version
78-
rm npm-shrinkwrap.json
79-
npm shrinkwrap
65+
yarn add module_name@version
8066
```

0 commit comments

Comments
 (0)