Webpacker v3.0.0 Release Notes

Release Date: 2017-08-30 // over 6 years ago
  • โž• Added

    • resolved_paths option to allow adding additional paths webpack should lookup when resolving modules
      # config/webpacker.yml
      # Additional paths webpack should lookup modules
      resolved_paths: [] # empty by default
    
    • Webpacker::Compiler.fresh? and Webpacker::Compiler.stale? answer the question of whether compilation is needed. The old Webpacker::Compiler.compile? predicate is deprecated.

    • Dev server config class that exposes config options through singleton.

      Webpacker.dev_server.running?
    
    • Rack middleware proxies webpacker requests to dev server so we can always serve from same-origin and the lookup works out of the box - no more paths prefixing

    • env attribute on Webpacker::Compiler allows setting custom environment variables that the compilation is being run with

      Webpacker::Compiler.env['FRONTEND_API_KEY'] = 'your_secret_key'
    

    ๐Ÿ’ฅ Breaking changes

    Note: requires running bundle exec rails webpacker:install

    config/webpack/**/*.js:

    • โฌ†๏ธ The majority of this config moved to the @rails/webpacker npm package. webpacker:install only creates config/webpack/{environment,development,test,production}.js now so if you're upgrading from a previous version you can remove all other files.

    webpacker.yml:

    • ๐Ÿšš Move dev-server config options under defaults so it's transparently available in all environments

    • โž• Add new HMR option for hot-module-replacement

    • โž• Add HTTPS

    โœ‚ Removed

    • Host info from manifest.json, now looks like this:
      {
        "hello_react.js": "/packs/hello_react.js"
      }
    

    ๐Ÿ›  Fixed

    • Update webpack-dev-server.tt to respect RAILS_ENV and NODE_ENV values #502
    • 0๏ธโƒฃ Use 0.0.0.0 as default listen address for webpack-dev-server
    • ๐Ÿฑ Serve assets using localhost from dev server - #424
      dev_server:
        host: localhost
    
    • ๐Ÿ On Windows, ruby bin/webpacker and ruby bin/webpacker-dev-server will now bypass yarn, and execute via node_modules/.bin directly - #584

    ๐Ÿ’ฅ Breaking changes

    • โž• Add compile and cache_path options to config/webpacker.yml for configuring lazy compilation of packs when a file under tracked paths is changed #503. To enable expected behavior, update config/webpacker.yml:
        default: &default
          cache_path: tmp/cache/webpacker
        test:
          compile: true
    
        development:
          compile: true
    
        production:
          compile: false
    
    • ๐Ÿ”ง Make test compilation cacheable and configurable so that the lazy compilation only triggers if files are changed under tracked paths. 0๏ธโƒฃ Following paths are watched by default -
        ["app/javascript/**/*", "yarn.lock", "package.json", "config/webpack/**/*"]
    

    To add more paths:

      # config/initializers/webpacker.rb or config/application.rb
      Webpacker::Compiler.watched_paths << 'bower_components'