Skip to content

Instantly share code, notes, and snippets.

@m-ahmadi
Last active March 23, 2023 16:31
Show Gist options
  • Save m-ahmadi/e9e0c096fae875629ca8397ff4f59253 to your computer and use it in GitHub Desktop.
Save m-ahmadi/e9e0c096fae875629ca8397ff4f59253 to your computer and use it in GitHub Desktop.
How to integrate `rtlcss` into an Angular App.

Here's a solution using the ngx-build-plus pkg. (ng version: 9.1.6 )

  1. add ngx-build-plus to your angular project:
ng new myapp --style=scss --routing
cd myapp
ng add ngx-build-plus
  1. create a webpack.partial.js file in root of the project directory, and put the following in it:
const rtlcss = require('rtlcss');
const autoprefixer = require('autoprefixer');

module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: {plugins: [autoprefixer, rtlcss]}
            }
          },
          'sass-loader',
        ],
      },
    ],
  },
};
  1. install required packages: npm i postcss postcss-loader rtlcss autoprefixer -D
  2. run ng serve --extra-webpack-config webpack.partial.js -o

Done. Now all of your *.scss files will go through rtlcss and autoprefixer.

@catalinadorneanu
Copy link

Thank you so much for your time

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