Skip to content
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

Crossplatform solution for changing build directory #6211

Closed
TheKnarf opened this issue Jan 16, 2019 · 5 comments · Fixed by #8986
Closed

Crossplatform solution for changing build directory #6211

TheKnarf opened this issue Jan 16, 2019 · 5 comments · Fixed by #8986
Labels

Comments

@TheKnarf
Copy link

TheKnarf commented Jan 16, 2019

I need to change to build directory for using create-react-app.

In issue #3824 it was recommended to add a postbuild step:

  "postbuild": "cp build/* restapi/wwwroot"

That works, but pushing it a colleague working on windows started complaining that the build now crashes on his computer (since mv is not crossplatform).

Is there any way of doing this in create-react-app now in 2019 without ejecting?

@TheKnarf
Copy link
Author

TheKnarf commented Jan 16, 2019

I solved my own problem by making a postbuild.js script using the copy package:

const copy = require('copy');
copy('build/**/*', 'restapi/wwwroot', function(err, files) {
  if (err) throw err;
});

and changing package.json into:

"postbuild": "node ./postbuild.js"

However I still think there should be a standard way to configure this as its a fairly common usecase.

@ianschmitz
Copy link
Contributor

You could use a package like ncp which works cross platform.

@TheKnarf
Copy link
Author

@iainbeeston see my second comment, I already fixed it with those tree lines and the copy package. But I'm still hoping for a "standard" / "built inn" way of doing it with create-react-app so that we don't need to add any other third party dependencies. Setting the build directory is obviously already supported in Webpack which create-react-app uses under the hood. However there's no way of changing the Webpack config without ejecting the app. A simple command line option to the build to override the output dir would be preferred.

@stale
Copy link

stale bot commented Feb 16, 2019

This issue 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 Feb 16, 2019
@stale
Copy link

stale bot commented Feb 21, 2019

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Feb 21, 2019
@lock lock bot locked and limited conversation to collaborators Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants