Skip to content

Crossplatform solution for changing build directory #6211

Closed
@TheKnarf

Description

@TheKnarf

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?

Activity

TheKnarf

TheKnarf commented on Jan 16, 2019

@TheKnarf
Author

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

ianschmitz commented on Jan 16, 2019

@ianschmitz
Contributor

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

TheKnarf

TheKnarf commented on Jan 16, 2019

@TheKnarf
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

stale commented on Feb 16, 2019

@stale

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 commented on Feb 21, 2019

@stale

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.

locked and limited conversation to collaborators on Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @TheKnarf@ianschmitz

      Issue actions

        Crossplatform solution for changing build directory · Issue #6211 · facebook/create-react-app