react-app-rewire-multiple-entry icon indicating copy to clipboard operation
react-app-rewire-multiple-entry copied to clipboard

Support allowing an entry's name to be specified?

Open bbeck opened this issue 5 years ago • 4 comments

Would you be open to a PR that allows users to specify the name (prefix) of an entry? I'm happy to do the work, just want to make sure it would be accepted if I did. It would look something like:

// config-overrides.js

const multipleEntry = require('react-app-rewire-multiple-entry')([
  {
    name: 'landing',   // <-- new property that would cause a filename of landing.[contenthash].chunk.js
    entry: 'src/entry/landing.js',
    template: 'public/landing.html',
    outPath: '/landing.html'
  }
]);

module.exports = {
  webpack: function(config, env) {
    multipleEntry.addMultiEntry(config);
    return config;
  }
};

In essence the change would be in the return statement of getValidSettings:

return {
  name: entry.name || formatName(entry.entry),   // <-- only call formatName if a name isn't specified
  entry: entryPath,
  template: entry.template,
  outPath: entry.outPath
};

This should be backwards compatible with all existing uses, but allow finer grained control over the naming of outputted files.

bbeck avatar Aug 06 '20 02:08 bbeck

@Derek-Hu It is really helpful to have entry name support, do you have a plan to add it?

kayali1411 avatar Aug 13 '20 05:08 kayali1411

+1

tSchubes avatar Sep 09 '20 06:09 tSchubes

The output entry name is friendly for most users: https://github.com/Derek-Hu/react-app-rewire-multiple-entry/issues/15

In case of entry name conflict unconsciously, customize entry name by user is allow.

Derek-Hu avatar Oct 29 '20 03:10 Derek-Hu

+1

syug avatar Oct 29 '20 03:10 syug