Loaders

Understanding Loaders

Loaders are transformations that are applied to the source code of a module. They allow you to pre-process files as you import or "load" them.

  • Transformation: Loaders can convert files from a different language (like TypeScript) to JavaScript.
  • Assets: They allow you to include resources like images or CSS directly in your JavaScript dependency graph.
  • Chaining: You can chain multiple loaders together (e.g., sass-loader -> css-loader -> style-loader).

Webpack enables use of loaders to preprocess files. This allows you to bundle any static resource way beyond JavaScript. You can easily write your own loaders using Node.js. Loaders are separate packages that extend webpack's capabilities and are maintained within the broader ecosystem. Loaders are activated by using loadername! prefixes in import .. from "mod";/require() statements, or are automatically applied via regex from your webpack configuration – see configuration.

Files

  • ref-loader Create dependencies between any files manually

JSON

Transpiling

Templating

Styling

Frameworks

Awesome

For more third-party loaders, see the list from awesome-webpack.

Edit this page·

9 Contributors

simon04bajrasrhys-vdwEugeneHlushkohemal7735snitin315anshumanvjamesgeorge007chenxsan