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

Usage with Webpack #52

Closed
kikoanis opened this issue Jan 1, 2016 · 12 comments
Closed

Usage with Webpack #52

kikoanis opened this issue Jan 1, 2016 · 12 comments

Comments

@kikoanis
Copy link

kikoanis commented Jan 1, 2016

It's not an issue but rather a question on how to use it with Webpack and postcss. My scenario is to produce two different packages one with RTL and the other is with LTR and to request one of them based on interface switching.

Any idea would be highly appreciated!

@MohammadYounes
Copy link
Owner

I haven't used Webpack before! Did you consider https://github.com/postcss/postcss-loader ?

@ai Your input is highly appreciated!

@ai
Copy link

ai commented Jan 1, 2016

OK. For example, you have two bundles: main.css and main.rtl.css.

Then, import main.css in main.rtl.css:

@import "../main.css";

And process *.rtl.css throw PostCSS with RTLCSS:

module.exports = {
    module: {
        loaders: [
            {
                test:   /\.rtl\.css$/,
                loader: "style-loader!css-loader!postcss-loader?pack=rtl"
            },
            {
                test:   /\.css$/,
                loader: "style-loader!css-loader!postcss-loader"
            }
        ]
    },
    postcss: function () {
        return {
            defaults: [autoprefixer, precss],
            rtl:  [rtlcss, autoprefixer, precss]
        };
    }
}

@ai
Copy link

ai commented Jan 1, 2016

But I am not really webpack user (for now, I prefer Browserify, because webpack API is ugly). So I can only show you a start point.

@MohammadYounes
Copy link
Owner

Thanks @ai

@kikoanis
Copy link
Author

kikoanis commented Jan 1, 2016

Thanks. I get the idea except I feel that importing main.css within main.rtl is a bit redundant and I guess it is a work around webpack that will only generate one file per entry. I will try to play with this a little bit and see how it goes and report back here. thanks again both.

@MohammadYounes
Copy link
Owner

Closing this as it's out of scope, but feel free to post here if you figure out a solution.

@loick
Copy link

loick commented Feb 25, 2016

I have the exact same question actually but the answer of creating another rtl file is a bit weird actually. By using the extract-text-webpack-plugin, we should be able to generate the main.ltr.css file and the main.rtl.css file without even duplicating anything.

I will digg into it

@MohammadYounes
Copy link
Owner

Cool ... Thanks!

@romainberger
Copy link

Hi, I've started a webpack plugin to produce a second bundle processed with rtlcss: https://github.com/romainberger/webpack-rtl-plugin (available on npm). It's meant to be used with the extract-text-webpack-plugin.

Hope this helps you, feedback appreciated!

@MohammadYounes
Copy link
Owner

Awesome 👍

@romainberger
Copy link

Small update if people are still interested, I've made a rtl-css-loader for webpack to replace the basic css-loader so you can have rtl css with the style-loader. Can be useful if you're using the style-loader for dev.

@Seb33300
Copy link

Seb33300 commented Aug 4, 2021

Hello, anything new related to rtlcss usage with webpack?
Any easy way to do it without installing a third party plugin?

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

6 participants