9

I want to use Tailwind CSS for my react apps. The problem is CRACO start starts the app on the default port, which is 3000 and I want to have custom ports but I can't figure out what is the right approach. ( Can't find anything about this in their documentation )

I tried something like PORT=5000 CRACO start inside the scripts field of the package.json file but doesn't work. Any idea?

2 Answers 2

22

The accepted answer contains links to the relevant information, but in case they become invalid or you are too lazy to look at them here is the config you need to add to your craco.config.js file.

module.exports = {
  devServer: {
    port: 5000
  }
}

Note that devServer is a top level property in the config.

Sign up to request clarification or add additional context in comments.

2 Comments

Any quick explanations as to why devServer is top-level instead of under webpack: config?
4

CRACO use the webpack devserver configuration to set the port.

you need to create a configuration. read more here in the readme:

https://github.com/gsoft-inc/craco/blob/master/packages/craco/README.md#configuration-file

So you solution need to redefine devServer. How to define it read in the webpack documentation:

https://webpack.js.org/configuration/dev-server/#devserver

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.