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

both rtl and lrt css files added to asset list #8

Open
elad-maimon opened this issue Nov 8, 2016 · 4 comments
Open

both rtl and lrt css files added to asset list #8

elad-maimon opened this issue Nov 8, 2016 · 4 comments

Comments

@elad-maimon
Copy link

Somewhere in between version 1.3.0 to 1.5.0 the plugin behaviour was changed and now all files created by the plugin are added to the asset list, hence, added to every html file created by HtmlWebpackPlugin regardless if this is a rtl html file or ltr.

@shem86
Copy link

shem86 commented May 23, 2017

@elad-maimon how did you overcome this issue?

@elad-maimon
Copy link
Author

I wrote my own plugin to integrate webpack-rtl-plugin with html-webpack-plugin, which explicitly changes the stylesheet tag from .css to *.rtl.css, if the dir is "rtl".

This is the code of my plugin:

function RtlHtmlWebpackPlugin(options) {
  this.options = options
}

RtlHtmlWebpackPlugin.prototype.apply = function(compiler) {
  compiler.plugin('compilation', function(compilation) {
    compilation.plugin('html-webpack-plugin-alter-asset-tags', function(htmlPluginData, callback) {
      if (htmlPluginData.plugin.options.dir === 'rtl') {
        htmlPluginData.head.forEach(function(tag) {
          tag.attributes.href = tag.attributes.href.replace(/css$/, 'rtl.css')
        })
      }

      callback(null, htmlPluginData)
    })
  })
}

module.exports = RtlHtmlWebpackPlugin

@shem86
Copy link

shem86 commented May 24, 2017

Oh thanks!
I ended up using HtmlWebpackExcludeAssetsPlugin.

@wessamzaghloul
Copy link

@elad-maimon would you please explain how you use your own plugin ?

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

3 participants