docbrown/docs/frontend/webpacker.md
rhymes 9210f6793b Improvements on dev docs (#2616)
* Correct installation documentation

* Add stylized titles

* Add some changes to the getting started documentation

* Add changes for the backend guide

* Add changes for the design guide

* Add testing / Q&A guide improvements

* Minor fixes to contributing docs

* More improvements to the general doc

* Improvements for frontend guide
2019-04-29 18:54:29 -04:00

869 B

title
Webpacker

Webpacker

DEV has two Javascript codebases.

One contains plain Javascript and you can read about in its own guide.

The other one is managed by Webpacker and it's located inside /app/javascripts, written using ES6+.

Currently it's mainly used for Preact components, served via webpack which is integrated into the Rails app using Webpacker.

There is a packs directory /app/javascript/packs where you can create new "pack" files. Pack files are initializers for Webpacker.

Since DEV is not a Single Page Application (SPA), Preact components are mounted as needed by including the pack file in the view files.

For example:

<%= javascript_pack_tag "webShare", defer: true %>

The include statement corresponds to the pack app/javascripts/packs/webShare.js