Webpacker: The output directory in the config should be the output directory

Created on 6 Apr 2017  路  4Comments  路  Source: rails/webpacker

@gauravtiwari

We're making webpacker work with
https://github.com/shakacode/react_on_rails-with-webpacker/pull/2

@robwise commented:

> The nice thing about putting the new entry points in /client/app/packs is that this would allow JS devs to add entry points without modifying the webpack configs.

This isn't true if you are doing any of the following:

* server-rendering (this requires two configs in the same env, something using webpacker to run your configs can't handle)
* DLL bundle (this requires two configs in the same env, something using webpacker to run your configs can't handle)
* common chunks plugin (you need to add entry points as separate chunks, so you're still modifying your webpack config when adding new entry points)

Thus, for React on Rails apps, we鈥檙e 100% going to NOT use the /packs/*.js for the entry points.

Given that, the current yml naming is a bit confusing:

output should be the real output dir to use for the custom webpack config. This should also be the place where webpacker finds the manifest.json. And the custom webpack config should use that.

2017-04-04_21-02-12

Most helpful comment

I also wanted to tweak the output directory and was thwarted by the 'behind the scenes' behavior.

Here's a suggestion for an alternative syntax:

source: app/javascript
entry: packs
dest: public
output: webpack     # optional - defaults to `entry` setting
config: config/webpack
node_modules: node_modules

All 4 comments

I also wanted to tweak the output directory and was thwarted by the 'behind the scenes' behavior.

Here's a suggestion for an alternative syntax:

source: app/javascript
entry: packs
dest: public
output: webpack     # optional - defaults to `entry` setting
config: config/webpack
node_modules: node_modules

@andyl we probably want the output to be /public/assets/webpack, right?

@justin808 I think this syntax would work for your scenario

source: app/javascript
entry: packs
dest: public/assets
output: webpack
config: config/webpack
node_modules: node_modules

In this example, webpack assets would be written to /public/assets/webpack, and javascript_pack_tag would also generate a /public/assets/webpack path.

We can close this. React on Rails will use a fork of Webpacker, called webpacker_lite.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vtno picture vtno  路  3Comments

itay-grudev picture itay-grudev  路  3Comments

amandapouget picture amandapouget  路  3Comments

johan-smits picture johan-smits  路  3Comments

naps62 picture naps62  路  3Comments