Skip to content

Make allow customize /dist naming from consumer's package. #7172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Kyr
Copy link

@Kyr Kyr commented Jun 5, 2019

Motivation.
For the some reasons I would to have ability to customize naming in /dist. postbuild script approach not very comfortable and needs an appropriate modification of manifestos.

This approach use optional naming schema configuration in consumer's package.json, for example "flat" structure:

...
  "distNaming": {
    "output": {
      "development": {
        "filename": "bundle.js",
        "chunkFilename": "[name].chunk.js"
      },
      "production": {
        "filename": "[name].[contenthash:8].js",
        "chunkFilename": "[name].[contenthash:8].chunk.js"
      }
    },
    "media": {
      "filename": "[name].[hash:8].[ext]"
    },
    "files": {
      "filename": "[name].[hash:8].[ext]"
    },
    "css": {
      "filename": "[name].[contenthash:8].css",
      "chunkFilename": "[name].[contenthash:8].chunk.css"
    }
  }
...

Such config applied to default naming schema and then used in webpack's config factory.

- get all matched `npm_package` env's variable;
- update default naming schema;
- use updated schema in webpack config factory;
@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@Kyr Kyr marked this pull request as ready for review June 6, 2019 11:08
@bugzpodder
Copy link

I am not seeing this as being useful for anyone else so we'll likely not go for this. What is your use case for requiring custom naming?

@Kyr
Copy link
Author

Kyr commented Jun 21, 2019

I am not seeing this as being useful for anyone else so we'll likely not go for this. What is your use case for requiring custom naming?

In my opinion there are various use cases that required custom naming.
For example:

  • modify target folder for everything that not an image, e.g. use assets/... instead static/media/...;
  • modify filenaming or hash parameters (or even avoid hashing), e.g. instead static/css/[name].[contenthash:8].chunk.css define as styles/fragment.[name].css
  • in my case, that, it's correct, not very useful for anyone else, I must to be avoided any nesting structure (please don't ask why, not sure that I can explain it clearly, it's legacy);

I'm would not to do eject due to lost gain and gain pain - it's not that I really want.

--scripts-version approach works well for me for the moment, but I would suggest that similar problem could resolved with RCA it self.

Perhaps exists other approach for the same thing, would you like to apoint me?

@stale
Copy link

stale bot commented Jul 21, 2019

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jul 21, 2019
@mrmckeb mrmckeb self-assigned this Jul 22, 2019
@stale stale bot removed the stale label Jul 22, 2019
@mrmckeb
Copy link
Contributor

mrmckeb commented Jul 22, 2019

We have discussed a config file for CRA in the past, but for now we have decided that it's not a priority @Kyr. As @bugzpodder stated, I'm also concerned that this has little value for most users.

Like you, I need this for a project I work on, and we also use a custom fork of react-scripts to achieve this. I think that's the safest approach for now.

Thanks for your time, and in future, I'd suggest raising an issue before a PR so we can discuss it in more detail there :)

@mrmckeb mrmckeb closed this Jul 22, 2019
@lock lock bot locked and limited conversation to collaborators Jul 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants