On this page
Loaders
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 activated by using loadername! prefixes in require() statements, or are automatically applied via regex from your webpack configuration – see configuration.
Files
raw-loaderLoads raw content of a file (utf-8)val-loaderExecutes code as module and consider exports as JS codeurl-loaderWorks like the file loader, but can return a data URL if the file is smaller than a limitfile-loaderEmits the file into the output folder and returns the (relative) URLref-loaderCreate dependencies between any files manually
JSON
json-loaderLoads a JSON file (included by default)json5-loaderLoads and transpiles a JSON 5 filecson-loaderLoads and transpiles a CSON file
Transpiling
script-loaderExecutes a JavaScript file once in global context (like in script tag), requires are not parsedbabel-loaderLoads ES2015+ code and transpiles to ES5 using Babelbuble-loaderLoads ES2015+ code and transpiles to ES5 using Bublétraceur-loaderLoads ES2015+ code and transpiles to ES5 using Traceurts-loaderorawesome-typescript-loaderLoads TypeScript 2.0+ like JavaScriptcoffee-loaderLoads CoffeeScript like JavaScriptfengari-loaderLoads Lua code using fengarielm-webpack-loaderLoads Elm like JavaScript
Templating
html-loaderExports HTML as string, require references to static resourcespug-loaderLoads Pug and Jade templates and returns a functionmarkdown-loaderCompiles Markdown to HTMLreact-markdown-loaderCompiles Markdown to a React Component using the markdown-parse parserposthtml-loaderLoads and transforms a HTML file using PostHTMLhandlebars-loaderCompiles Handlebars to HTMLmarkup-inline-loaderInline SVG/MathML files to HTML. It’s useful when applying icon font or applying CSS animation to SVG.twig-loaderCompiles Twig templates and returns a function
Styling
style-loaderAdd exports of a module as style to DOMcss-loaderLoads CSS file with resolved imports and returns CSS codeless-loaderLoads and compiles a LESS filesass-loaderLoads and compiles a SASS/SCSS filepostcss-loaderLoads and transforms a CSS/SSS file using PostCSSstylus-loaderLoads and compiles a Stylus file
Linting && Testing
mocha-loaderTests with mocha (Browser/NodeJS)eslint-loaderPreLoader for linting code using ESLintjshint-loaderPreLoader for linting code using JSHintjscs-loaderPreLoader for code style checking using JSCScoverjs-loaderPreLoader to determine the testing coverage using CoverJS
Frameworks
vue-loaderLoads and compiles Vue Componentspolymer-loaderProcess HTML & CSS with preprocessor of choice andrequire()Web Components like first-class modulesangular2-template-loaderLoads and compiles Angular Components
Awesome
For more third-party loaders, see the list from awesome-webpack.
© JS Foundation and other contributors
Licensed under the Creative Commons Attribution License 4.0.
https://v4.webpack.js.org/loaders/