Skip to content

Rails doesn't notice webpack-dev-server running when RAILS_ENV=test #1633

@ryanscottaudio

Description

@ryanscottaudio

Every time I try to load a JS file through Rails when RAILS_ENV=test, I get [Webpacker] [INFO] Compiling… in the console, even if in another console window i have RAILS_ENV=test ./bin/webpack-dev-server running. Here's my webpacker.yml:

# Note: You must restart bin/webpack-dev-server for changes to take effect

default: &default
  source_path: app/javascript
  source_entry_path: packs
  public_output_path: packs
  cache_path: tmp/cache/webpacker

  # Additional paths webpack should lookup modules. If adding to this, also add to test.resolved_paths in this file
  resolved_paths:
    - 'app/assets/js'
    - 'vendor/assets/javascripts'
    - 'node_modules'

  # Reload manifest.json on all requests so we reload latest compiled packs
  cache_manifest: false

  extensions:
    - .js.coffee.erb
    - .js.coffee
    - .jst.eco
    - .js
    - .es6.jsx

development:
  <<: *default
  compile: true

  # Reference: https://webpack.js.org/configuration/dev-server/
  dev_server:
    https: false
    host: localhost
    port: 3035
    public: localhost:3035
    hmr: true
    # Inline should be set to true if using HMR
    inline: true
    overlay: true
    compress: true
    disable_host_check: true
    use_local_ip: false
    quiet: false
    headers:
      'Access-Control-Allow-Origin': '*'
    watch_options:
      ignored: /node_modules/

test:
  <<: *default
  compile: true

  # Compile test packs from/to a separate directory
  source_path: spec/javascripts
  source_entry_path: packs
  public_output_path: packs-test

  resolved_paths:
    - 'app/assets/js'
    - 'vendor/assets/javascripts'
    - 'node_modules'
    - 'spec/javascripts/helpers'

  # Reference: https://webpack.js.org/configuration/dev-server/
  dev_server:
    https: false
    host: localhost
    port: 3035
    public: localhost:3035
    hmr: true
    # Inline should be set to true if using HMR
    inline: true
    overlay: true
    compress: true
    disable_host_check: true
    use_local_ip: false
    quiet: false
    headers:
      'Access-Control-Allow-Origin': '*'
    watch_options:
      ignored: /node_modules/

staging:
  <<: *default

  # Production depends on precompilation of packs prior to booting for performance.
  compile: false

  # Cache manifest.json for performance
  cache_manifest: true

production:
  <<: *default

  # Production depends on precompilation of packs prior to booting for performance.
  compile: false

  # Cache manifest.json for performance
  cache_manifest: true

The purpose of running webpack-dev-server in test mode is just so that I can edit code to fix tests more efficiently (without webpack having to bundle all the affected files any time i want to load them); I wouldn't be running this in any sort of CI setting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependenciesdependency, yarn or other package managementwebpack

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions