Webpacker: Cannot use pack filename `application.*.js`

Created on 8 Aug 2018  路  1Comment  路  Source: rails/webpacker

I want to use pack filename like this:

  • packs/application.react.js
    <%= javascript_pack_tag 'application.react' %> (in layout erb file)
  • packs/application.vue.js
    <%= javascript_pack_tag 'application.vue' %> (in layout erb file)

馃憤 Expected behavior:

// manifest.json
{
  :
  "application.react.js": "/packs/application.react-4543357cf6a6fee4f0541020f60fa1d5.js",
  "application.vue.js": "/packs/application.vue-4543357cf6a6fee4f0541020f60fa1d5.js",
  :
  :
}

馃憥 But, Current behavior is:

// manifest.json
{
  :
  "application.js": "/packs/application-4543357cf6a6fee4f0541020f60fa1d5.js",
  :
  :
}

.react and .vue disappeared from the file name馃槶

How can I prevent this behavior?

Most helpful comment

As far as I can see, the name is collected here:

https://github.com/rails/webpacker/blob/af471dcb4ae32cfebd43dc5ad4d037b7fe6d00fc/package/environment.js#L46

and then output here:

https://github.com/rails/webpacker/blob/af471dcb4ae32cfebd43dc5ad4d037b7fe6d00fc/package/environment.js#L65-L66

To change this, you'd need to overwrite in your app by merging on top of the default config. The best place would likely be inside of your config/webpack/environment.js file

Here is a helper webpack guide:
https://webpack.js.org/configuration/output/

That being said, it is probably a much better idea for you to go with something like a dash or underscore (application-react or application_react) instead of a period (application.react) because as soon as you overwrite the default, you own your problem.

>All comments

As far as I can see, the name is collected here:

https://github.com/rails/webpacker/blob/af471dcb4ae32cfebd43dc5ad4d037b7fe6d00fc/package/environment.js#L46

and then output here:

https://github.com/rails/webpacker/blob/af471dcb4ae32cfebd43dc5ad4d037b7fe6d00fc/package/environment.js#L65-L66

To change this, you'd need to overwrite in your app by merging on top of the default config. The best place would likely be inside of your config/webpack/environment.js file

Here is a helper webpack guide:
https://webpack.js.org/configuration/output/

That being said, it is probably a much better idea for you to go with something like a dash or underscore (application-react or application_react) instead of a period (application.react) because as soon as you overwrite the default, you own your problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

suhomozgy-andrey picture suhomozgy-andrey  路  3Comments

amandapouget picture amandapouget  路  3Comments

Eearslya picture Eearslya  路  3Comments

FrankFang picture FrankFang  路  3Comments

ankitrg picture ankitrg  路  3Comments