Fix distDir layout for advanced webpack features #127
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Right now this gem is built on the assumption that
app/javascript/packs
will always matchpublic/packs
. This holds when the JS entry points are the only files emitted and avoids users having to mess withpublicPath
in the webpack config.But this isn't going to be the case for most webpack-based apps of any complexity. Eg, file-loader breaks this assumption. I believe it gets broken under a number of other scenarios as well: commons chunks, ExtractTextPlugin, some kinds of code splitting, etc.
These are not scenarios we need to support out-of-the-box, but per #109 it makes sense to set up defaults that make them possible.
The easiest solution I could think of was to make the structure of the "packs" dir match the structure of
app/javascript
.Let's say your
app/javascript
dir looked like this:If you ran
bin/webpack
, yourpublic/packs
dir would look like this:Doh! Images is now a sibling of your pack files! The structure doesn't match the structure of
app/javascript
, causing the need for additional configuration and pain. Instead let's make it look like this:Nice, it matches! I also renamed the top-level dir from
packs
todist
to make clear that it's not the equivalent of thepacks
dir inapp/javascript
, and becauseassets
was already taken.Thoughts? Any lower-impact alternatives?
cc @gauravtiwari