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

Create-react-app Integration Question #134

Open
dsuriano opened this issue Dec 20, 2018 · 8 comments
Open

Create-react-app Integration Question #134

dsuriano opened this issue Dec 20, 2018 · 8 comments

Comments

@dsuriano
Copy link

I'm developing an app that I would like to integrate rtlcss into that uses create-react-app and its default settings. I'm trying to avoid ejecting or installing a new task manager or build system (ie: grunt/gulp).

My goal is to have rtlcss run whenever a change is detected within any .scss or .css file, in order to simultaneously dev/test without having to manually run the rtlcss from the CLI every time.

Does anyone have recommendations on what is the best way to achieve this goal?

@masanzsa
Copy link

Version the app in GitHub or SVN or any other similar repo, then create a script to monitor the changes by updating it to a folder regularly; upon there is an addition or an update of any of the mentioned files trigger a rule to process them as desired and push the changes back to your repo.

@dsuriano
Copy link
Author

dsuriano commented Dec 24, 2018

@masanzsa That would work fine for a production build process using webhooks, but not so well for a local development environment while constantly tweaking code and testing the results.

I specifically need something for local development that integrates into create-react-app.

@Shaker-Hamdi
Copy link

@dsuriano Did you find a solution to this? I'm facing the same issue, I need to use this package with create-react-app, and I would like to have two CSS files to switch between them based on a state prop in both development and production.

@dsuriano
Copy link
Author

dsuriano commented Feb 1, 2019

@Shaker-Hamdi Unfortunately my deadlines prevented me from implementing a solution. I ended up manually converting 15-20 files and it helped put me into the habit of writing any future styles with RTL support in mind from the start.

My initial thoughts for a solution were something along the lines of writing a small Node script, using npm-watch, or something like Rollup.js that would watch for changes in scss or css files, then run rtlcss with the desired configs. Once you have that working, you could add the new script to your package.json scripts definition. Something like:

{
  "scripts": {
    "start": "react-scripts start && add-the-new-script-here"
  }
}

Good luck! And if you stumble across a solution, let me know.

@m-ahmadi
Copy link

m-ahmadi commented Jun 4, 2020

Here's a solution using craco:

  1. create a craco.config.js in root of your project and put the following in it:
const rtlcss = require('rtlcss');

module.exports = {
  style: {
    postcss: {
      plugins: [rtlcss]
    }
  }
};
  1. edit the scripts field of your project's package.json:
"scripts": {
  "start": "craco start",
  "build": "craco build",
  "test": "craco test",
},
  1. install needed packages: npm i @craco/craco rtlcss sass -D

  2. run npm start

Done.

@iamshaheenumar
Copy link

Problem with the above solution is that, RTLCSS requires PostCSS 8.
create-react-app is not supporting PostCSS 8 now. Hence its throwing an error

@musaab-abdalla
Copy link

Problem with the above solution is that, RTLCSS requires PostCSS 8.
create-react-app is not supporting PostCSS 8 now. Hence its throwing an error

Downgrade your rtlcss to use version 2.6.2

@parsagholipour
Copy link

Here's a solution using craco:

  1. create a craco.config.js in root of your project and put the following in it:
const rtlcss = require('rtlcss');

module.exports = {
  style: {
    postcss: {
      plugins: [rtlcss]
    }
  }
};
  1. edit the scripts field of your project's package.json:
"scripts": {
  "start": "craco start",
  "build": "craco build",
  "test": "craco test",
},
  1. install needed packages: npm i @craco/craco rtlcss sass -D
  2. run npm start

Done.

It doesn't work.
craco: 7.0.0-alpha.7
rtlcss: 3.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants