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

Ignoring css from the other libraries in node modules #23

Open
eneyed opened this issue Mar 30, 2016 · 2 comments
Open

Ignoring css from the other libraries in node modules #23

eneyed opened this issue Mar 30, 2016 · 2 comments

Comments

@eneyed
Copy link

eneyed commented Mar 30, 2016

Hi,

I am using a javascript plugin and its default stylesheets (by referring from the node_modules directory). When I enable the css modules, even the stylesheets referred from the directory gets locally scoped with hash. However, the class names from this plugin does not reflect the scoped names within the HTML, for obvious reasons that the plugin hasn't been written the css modules.

How can I ignore scoping of the stylesheets coming from the node_modules? Or what is the best way for the current scenario?

Thanks in advance!

@cristiano-belloni
Copy link

+1

@bluedaniel
Copy link

If anyone lands here I got round the issue by simply ignoring node_modules (or the folder that contains 3rd party css) and then another loader underneath for the 3rd party scripts.

{
  test: /\.css$/,
  exclude: /node_modules/, // Ignore the folder containing 3rd party scripts
  loader: ExtractTextPlugin.extract({
    loader: [
      {
        loader: 'css-loader',
        query: {
          modules: true,
          localIdentName: '[name]_[local]_[hash:base64:3]'
        }
      },
      'postcss-loader'
    ]
  })
}, {
  test: /leaflet.css$/, // A file or folder containing CSS you don't want mangled
  loader: ExtractTextPlugin.extract({
    loader: [
      {
        loader: 'css-loader',
        query: {
          modules: true,
          localIdentName: '[local]' // This will ensure the classname remains as it is
        }
      },
      'postcss-loader'
    ]
  })
}

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