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

How to import external CSS without changing class names #503

Open
gpalsingh opened this issue Sep 15, 2020 · 0 comments
Open

How to import external CSS without changing class names #503

gpalsingh opened this issue Sep 15, 2020 · 0 comments

Comments

@gpalsingh
Copy link

When I try to import CSS from node_modules the loader renames all the class names

I found one workaround here
This is what I'm using:

const loadCSS = isServerConfig => ({
	module: {
		rules: [
			{
				test: /\.css$/,
				oneOf: [{
					resourceQuery: /^\?raw$/,
					use: [
						...(isServerConfig ? [] : [ExtractCSSChunks.loader]),
						{
							loader: require.resolve('css-loader'),
							options: {
								onlyLocals: isServerConfig,
							},
						},
					]
				}, {
					use: [
						...(isServerConfig ? [] : [ExtractCSSChunks.loader]),
						{
							loader: require.resolve('css-loader'),
							options: {
								modules: {
									localIdentName: '[name]__[local]--[hash:base64:5]',
								},
								onlyLocals: isServerConfig,
							},
						},
					],
				}]
			},
		],
	},
});

Is there a better way to do it?

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