Skip to content

Commit 625119c

Browse files
Merge pull request #3198 from justin808/patch-22
Better v6 Upgrade Instructions
2 parents e039a2f + b4362a4 commit 625119c

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

docs/v6_upgrade.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,21 @@ Webpacker used to configure Webpack indirectly, which lead to a [complicated sec
1010

1111
This means you have to configure integration with frameworks yourself, but webpack-merge helps with this. See this example for [Vue](https://github.com/rails/webpacker#other-frameworks).
1212

13-
## How to upgrade to Webpacker 6
13+
## How to upgrade to Webpacker v6 from v5
14+
1. If you are changing from the v5 default for `source_entry_path`:
15+
```yml
16+
source_path: app/javascript
17+
source_entry_path: packs
18+
```
19+
to the v6 default:
20+
```yml
21+
source_path: app/javascript
22+
source_entry_path: /
23+
```
24+
Then move your `app/javascript/packs/*` (including `application.js`) to `app/javascript/`.
25+
26+
Check if you had any entry point files in child directories of your `source_entry_path`. Files for entry points in child directories are not supported by rails/webpacker v6.
1427

15-
1. Move your `app/javascript/packs/application.js` to `app/javascript/application.js`
1628
2. Rename `config/webpack` to `config/webpack_old`
1729
3. Rename `config/webpacker.yml` to `config/webpacker_old.yml`
1830
4. Uninstall the current version of `webpack-dev-server`: `yarn remove webpack-dev-server`
@@ -75,3 +87,9 @@ Example going to a specific version:
7587
14. Some dependencies were removed in [PR 3056](https://github.com/rails/webpacker/pull/3056). If you see the error: `Error: Cannot find module 'babel-plugin-macros'`, or similar, then you need to `yarn add <dependency>` where <dependency> might include: `babel-plugin-macros`, `case-sensitive-paths-webpack-plugin`, `core-js`, `regenerator-runtime`. Or you might want to remove your dependency on those.
7688
15. If you run `RAILS_ENV=production rake assets:precompile`, you may get an error that `bin/yarn` does not exist. Copy the file [bin/yarn](https://github.com/rails/webpacker/blob/master/lib/install/bin/yarn) to your `/bin` directory.
7789
16. Remove overlapping dependencies from your `package.json` and rails/webpacker's `package.json`. For example, don't include `webpack` directly as that's a dependency of rails/webpacker.
90+
17. Review the new default's changes to `webpacker.yml` and `config/webpack`. Consider each suggested change carefully, especially the change to have your `source_entry_path` be at the top level of your `source_path`.
91+
18. Make sure that you can run `bin/webpack` without errors before trying your app!
92+
93+
## Examples of v5 to v6
94+
1. [React on Rails Project with HMR and SSR](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/compare/webpacker-5.x...master)
95+
2. [Vue and Sass Example](https://github.com/guillaumebriday/upgrade-webpacker-5-to-6)

0 commit comments

Comments
 (0)