Sha256: 47f2fef9abc37cfcd5bac96aa5df9ffd81eeffc56061550e0555ac5f889990d8

Contents?: true

Size: 1.26 KB

Versions: 70

Compression:

Stored size: 1.26 KB

Contents

# Folder Structure


## Packs a.k.a webpack entries

"Packs" is a special directory made only for webpack entry files so don't put anything
here that you don't want to link in your views.


## Source

You can put your app source under `app/javascript` folder or whatever you have configured
in `config/webpacker.yml`.


## Example

Let's say you're building a calendar app. Your JS app structure could look like this:

```js
// app/javascript/packs/calendar.js

import 'calendar'
```

```
app/javascript/calendar/index.js // gets loaded by import 'calendar'
app/javascript/calendar/components/grid.jsx
app/javascript/calendar/styles/grid.sass
app/javascript/calendar/models/month.js
```

```erb
<%# app/views/layouts/application.html.erb %>

<%= javascript_pack_tag 'calendar' %>
<%= stylesheet_pack_tag 'calendar' %>
```

But it could also look a million other ways.


## Namespacing

You can also namespace your packs using directories similar to a Rails app.

```
app/javascript/packs/admin/orders.js
app/javascript/packs/shop/orders.js
```

and reference them in your views like this:

```erb
<%# app/views/admin/orders/index.html.erb %>

<%= javascript_pack_tag 'admin/orders' %>
```

and

```erb
<%# app/views/shop/orders/index.html.erb %>

<%= javascript_pack_tag 'shop/orders' %>
```

Version data entries

70 entries across 70 versions & 5 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/docs/folder-structure.md
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/docs/folder-structure.md
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/docs/folder-structure.md
jetpacker-0.7.0 docs/folder-structure.md
webpacker-5.4.4 docs/folder-structure.md
jetpacker-0.6.0 docs/folder-structure.md
webpacker-5.4.3 docs/folder-structure.md
webpacker-5.4.2 docs/folder-structure.md
webpacker-5.4.1 docs/folder-structure.md
webpacker-5.4.0 docs/folder-structure.md
webpacker-5.3.0 docs/folder-structure.md
webpacker-5.2.2 docs/folder-structure.md
jetpacker-0.5.0 docs/folder-structure.md
webpacker-6.0.0.pre.2 docs/folder-structure.md
webpacker-6.0.0.pre.1 docs/folder-structure.md
webpacker-5.2.1 docs/folder-structure.md
webpacker-4.3.0 docs/folder-structure.md
webpacker-5.2.0 docs/folder-structure.md
webpacker-5.1.1 docs/folder-structure.md
webpacker-5.1.0 docs/folder-structure.md