Css-loader: Where is documentation for [path], [name] and [local] variables?

Created on 31 Jan 2016  路  8Comments  路  Source: webpack-contrib/css-loader

Documentation (https://github.com/webpack/css-loader#local-scope) mentions these variables in one of the examples:

You can configure the generated ident with the localIdentName query parameter (default [hash:base64]). Example: css-loader?localIdentName=[path][name]---[local]---[hash:base64:5] for easier debugging.

I cannot find more documentation. Specifically what variables are available aside from [path], [name] and [local]?

Most helpful comment

Copied from https://github.com/webpack/loader-utils:

The following tokens are replaced in the name parameter:

  • [ext] the extension of the resource
  • [name] the basename of the resource
  • [path] the path of the resource relative to the context query parameter or option.
  • [folder] the folder of the resource is in.
  • [emoji] a random emoji representation of options.content
  • [emoji:<length>] same as above, but with a customizable number of emojis
  • [hash] the hash of options.content (Buffer) (by default it's the hex digest of the md5 hash)
  • [<hashType>:hash:<digestType>:<length>] optionally one can configure

    • other hashTypes, i. e. sha1, md5, sha256, sha512

    • other digestTypes, i. e. hex, base26, base32, base36, base49, base52, base58, base62, base64

    • and length the length in chars

  • [N] the N-th match obtained from matching the current file name against options.regExp

All 8 comments

I have looked into extract-text-webpack-plugin documentation and it only mentions (https://github.com/webpack/extract-text-webpack-plugin#api):

filename the filename of the result file. May contain [name], [id] and [contenthash].

  • [name] the name of the chunk
  • [id] the number of the chunk
  • [contenthash] a hash of the content of the extracted file

Was looking up for the same info, found this: https://github.com/webpack/loader-utils/blob/master/index.js#L197

It seems that ext, name, path and hash are the only tokens available. Then, there is the regExp thingy but I don't know yet how to use it.

@qur2 always include commit or a tag when referring to the source code, e.g. https://github.com/webpack/loader-utils/blob/v0.2.12/index.js#L197

Otherwise link becomes historically useless as soon as any changes have been made to that file.

Alright, that makes sense, thanks for the advice.

From duped issue:

[name]
[local]
[path]
[hash:base64:5]
folder
ext
emoji:XXXX

loader-utils repo and/or hopefully on webpack.js.org :)

So is there a place in the documentation that covers these?

Copied from https://github.com/webpack/loader-utils:

The following tokens are replaced in the name parameter:

  • [ext] the extension of the resource
  • [name] the basename of the resource
  • [path] the path of the resource relative to the context query parameter or option.
  • [folder] the folder of the resource is in.
  • [emoji] a random emoji representation of options.content
  • [emoji:<length>] same as above, but with a customizable number of emojis
  • [hash] the hash of options.content (Buffer) (by default it's the hex digest of the md5 hash)
  • [<hashType>:hash:<digestType>:<length>] optionally one can configure

    • other hashTypes, i. e. sha1, md5, sha256, sha512

    • other digestTypes, i. e. hex, base26, base32, base36, base49, base52, base58, base62, base64

    • and length the length in chars

  • [N] the N-th match obtained from matching the current file name against options.regExp
Was this page helpful?
0 / 5 - 0 ratings

Related issues

heldrida picture heldrida  路  4Comments

tapz picture tapz  路  3Comments

dmiller9911 picture dmiller9911  路  3Comments

mareksuscak picture mareksuscak  路  5Comments

jonathanong picture jonathanong  路  3Comments