react-app-rewire-styled-components icon indicating copy to clipboard operation
react-app-rewire-styled-components copied to clipboard

Compatible with react-scripts-ts?

Open mikewheaton opened this issue 7 years ago • 4 comments

I'm attempting to get this working with a Create React App project that's using react-scripts-ts. Here's what I've tried:

  1. npm install --save-dev babel-plugin-styled-components
  2. npm install --save react-app-rewire-styled-components
  3. npm install --save-dev react-app-rewired
  4. Add a config-overrides.js file to the root:
const rewireStyledComponents = require('react-app-rewire-styled-components');

module.exports = function override(config, env) {
  config = rewireStyledComponents(config, env, {
    displayName: true
  });
  return config;
}
  1. Add a .babelrc file to the root:
{
  "plugins": ["babel-plugin-styled-components"]
}

  1. Update package.json:
    "start": "react-app-rewired start --scripts-version react-scripts-ts",
    "build": "react-app-rewired build --scripts-version react-scripts-ts",
    "test": "react-app-rewired test --env=jsdom --scripts-version react-scripts-ts",
  1. npm start

Unfortunately, it doesn't seem to be working as the friendly class names aren't included: image

Do you have any ideas on what I might try next to get this working?

mikewheaton avatar Oct 11 '18 02:10 mikewheaton

What a coincidence... I just got the exact same issue. After I got this I also tested pure create-react-app, and it worked without a problem. Which means I guess react-scripts-ts can be a problem here. here are the versions I used. I tested styled-components with both v3 and v4 "react-scripts-ts": "3.1.0", "react-app-rewired": "^1.6.2", "react-app-rewire-styled-components": "^3.0.2",

lonyele avatar Oct 11 '18 16:10 lonyele

Thanks for confirming this, @lonyele, although I was hoping it wouldn't be the case. I'll leave the issue open in case anyone has ideas on how this might be fixed. With the popularity of react-scripts-ts there are likely others running into this.

mikewheaton avatar Oct 11 '18 16:10 mikewheaton

Did you guys find any fix for this?

yugandhar-pathi avatar Feb 14 '21 22:02 yugandhar-pathi

@yugandhar-pathi did you find a fix for this?

viny-movember avatar May 25 '22 19:05 viny-movember