webpacker

Webpacker: What is `source_entry_path` and `source_path`?


In Webpacker what is the difference between source_entry_path and source_path? I'm not seeing it explained in the documentation.


Solution

  • source_path: is the parent directory where your pack folders and files live.

    It is usually called javascript or frontend under app directory.

    app/javascript

    app/frontend

    source_entry_path defines your pack directory name and all your entry files go there. By convention it is called packs. Keep in mind that each entry file treated separately in this directory.

    These can be named anything you want, make sure these directories exist.

    So when you have <%= javascript_pack_tag 'application' %> in your layout file, webpacker knows to find application.js file in app/javascript/packs based on what you have for source_path: and source_entry_path in webpacker.yml