Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Webpack CSS-loader "localIdentName" Query Tag Placeholders?

I'm brand new to Webpack and have been playing around with the css-loader. On the Github page under "Local Scope" there's information about specifying a localIdentName query tag with your own custom values like: [path][name]---[local]---[hash:base64:5]. This tag allows us to specify how the class should be named after being processed.

Is it possible for us to define our own custom value placeholders for this query tag i.e. css-loader?localIdentName=[MyCustomMethod]-[hash:base64:5]?

like image 820
Benjamin Solum Avatar asked Jul 10 '15 18:07

Benjamin Solum


People also ask

How do I use CSS-loader with Webpack?

The css-loader interprets @import and url () like import/require () and will resolve them. To begin, you'll need to install css-loader: Then add the plugin to your webpack config. For example: And run webpack via your preferred method.

How to resolve @import and URL () in CSS-loader?

The css-loader interprets @import and url () like import/require () and will resolve them. To begin, you'll need to install css-loader: Then add the plugin to your webpack config.

How to use global class name as local name in CSS?

Allow css-loader to export names from global class or id, so you can use that as local name. Type: String|Function Default: based on the modules.namedExport option value, if true - camelCaseOnly, otherwise asIs Style of exported class names.

How to replace local selectors with unique identifiers in the loader?

The loader replaces local selectors with unique identifiers. The chosen unique identifiers are exported by the module. CamelCase is recommended for local selectors. They are easier to use within the imported JS module. You can use :local (#someId), but this is not recommended. Use classes instead of ids.


1 Answers

I don't think it is possible to put an arbitrary custom token there, but the documentation for loader-utils (which is used by css-loader) lists a number of other useful predefined tokens such as [folder] or [emoji]. Maybe they'll do?

like image 62
n1313 Avatar answered Sep 21 '22 02:09

n1313