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
webpacker-5.0.1 docs/folder-structure.md
webpacker-5.0.0 docs/folder-structure.md
jetpacker-0.4.2 docs/folder-structure.md
jetpacker-0.4.1 docs/folder-structure.md
jetpacker-0.4.0 docs/folder-structure.md
jetpacker-0.3.0 docs/folder-structure.md
jetpacker-0.2.0 docs/folder-structure.md
webpacker-4.2.2 docs/folder-structure.md
webpacker-4.2.1 docs/folder-structure.md
webpacker-4.2.0 docs/folder-structure.md
webpacker-4.1.0 docs/folder-structure.md
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/webpacker-4.0.7/docs/folder-structure.md
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/webpacker-4.0.7/docs/folder-structure.md
webpacker-4.0.7 docs/folder-structure.md
webpacker-4.0.6 docs/folder-structure.md
webpacker-4.0.5 docs/folder-structure.md
webpacker-4.0.4 docs/folder-structure.md
webpacker-4.0.3 docs/folder-structure.md
webpacker-4.0.2 docs/folder-structure.md
webpacker-3.6.0 docs/folder-structure.md