Formation Prestashop intégrateur: Loaders / file-loader

Vous êtes ici : Accueil / Prestashop intégrateur / Loaders / file-loader


file-loader

Ce plugin permet de simplifier la gestion du cache en renommant les fichiers avec un MD5 du contenu et de l'extension.

Installation :

 npm install file-loader

Paramètres pour la création du nom du fichier :

  • [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.
  • [hash] the hash of the content, hex-encoded md5 by default
  • [<hashType>:hash:<digestType>:<length>] optionally you 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 the query param regExp

Exemple d'utilisation :

{
    test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/,
    loader: 'file-loader?name=../css/[hash].[ext]'
};