This guide aims to help you migrating to webpacker 6. If you are using vanilla webpacker install then hopefully, the upgrade should be really straightforward.
- If your
source_path
isapp/javascript
, rename it toapp/packs
- If your
source_entry_path
isapp/javascript/packs
, rename it toapp/packs/entrypoints
- Rename
config/webpack
toconfig/webpack_old
- Rename
config/webpacker.yml
toconfig/webpacker_old.yml
- Uninstall the current version of
webpack-dev-server
:yarn remove webpack-dev-server
- Upgrade webpacker
# Gemfile
gem 'webpacker', '~> 6.0.0.pre.2'
bundle install
yarn add @rails/webpacker@next
bundle exec rails webpacker:install
- Change
javascript_packs_with_chunks_tag
andstylesheet_packs_with_chunks_tag
tojavascript_pack_tag
andstylesheet_pack_tag
.
-
If you are using any integrations like
css
,React
orTypeScript
. Please see https://github.com/rails/webpacker#integrations section on how they work in v6.0. -
Copy over any custom webpack config from
config/webpack_old
-
Common code previously called 'environment' changed to 'base'
-
import
environment
changed name towebpackConfig
.// config/webpack/base.js const { webpackConfig, merge } = require('@rails/webpacker') const customConfig = require('./custom') module.exports = merge(webpackConfig, customConfig)
-
Copy over custom browserlist config from
.browserlistrc
if it exists into the"browserlist"
key inpackage.json
and remove.browserslistrc
. -
extensions
was removed from the webpacker.yml file. Move custom extensions to your configuration by by merging an object like this. For more details, see docs for Webpack Configuration
{
resolve: {
extensions: ['.ts', '.tsx']
}
}