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

file-loader & css-loader doesn't handle paths in the /*rtl*/ comments #11

Open
Abdelhady opened this issue May 24, 2017 · 0 comments
Open

Comments

@Abdelhady
Copy link

Abdelhady commented May 24, 2017

tl;dr: file-loader & css-loader doesn't handle paths (like url(image-en.png)) in the /*rtl*/ comments.

details:

here is my webpack.config.js configuration:

const extractLESS = new ExtractTextPlugin('[contenthash].css');

module.exports = {
...
    module: {
        rules: [
            ...
            {
                test: /\.less$/i,
                use: extractLESS.extract(['css-loader', 'less-loader'])
            },
            {
                test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$|\.ogg$/,
                loader: "file-loader?name=[name]-[hash].[ext]"
            }
        ]
    },
    plugins: [
        ...
        extractLESS,
        new WebpackRTLPlugin(),
    ]
}

now when I write background-image like this:

.example
{
      background-image: url(image-en.png)/*rtl:url(image-ar.png)*/;
}

the result is like this:

.example
{
      background-image: url(https://mycdn.com/build/image-en-[generated-hash].png);
}

which removed the /*rtl*/ comment completely before generating the rtl version,

I tried another way by using the rtl:raw like this:

.example
{
     background-image: url(image-en.png);
    /*rtl:raw:
        background-image: url(image-ar.png);
    */;
}

which generated an unprocessed version of image-ar.png like:

.example
{
      background-image: url(https://mycdn.com/build/image-en-[generated-hash].png);
      background-image: url(image-ar.png);
}

So, how to make this plugin work well with the file-loader?

@Abdelhady Abdelhady changed the title File loader doesn't handle paths in the /*rtl*/ comments file-loader & css-loader doesn't handle paths in the /*rtl*/ comments May 24, 2017
@Abdelhady Abdelhady changed the title file-loader & css-loader doesn't handle paths in the /*rtl*/ comments file-loader & css-loader doesn't handle paths in the /*rtl*/ comments May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant