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 code -
url-loaderWorks like the file loader, but can return a data URL if the file is smaller than a limit -
file-loaderEmits the file into the output folder and returns the (relative) URL -
ref-loaderCreate dependencies between any files manually
JSON
-
json-loaderLoads a JSON file (included by default) -
json5-loaderLoads and transpiles a JSON 5 file -
cson-loaderLoads and transpiles a CSON file
Transpiling
-
script-loaderExecutes a JavaScript file once in global context (like in script tag), requires are not parsed -
babel-loaderLoads ES2015+ code and transpiles to ES5 using Babel -
buble-loaderLoads ES2015+ code and transpiles to ES5 using Bublé -
traceur-loaderLoads ES2015+ code and transpiles to ES5 using Traceur -
ts-loaderorawesome-typescript-loaderLoads TypeScript 2.0+ like JavaScript -
coffee-loaderLoads CoffeeScript like JavaScript -
fengari-loaderLoads Lua code using fengari -
elm-webpack-loaderLoads Elm like JavaScript
Templating
-
html-loaderExports HTML as string, require references to static resources -
pug-loaderLoads Pug and Jade templates and returns a function -
markdown-loaderCompiles Markdown to HTML -
react-markdown-loaderCompiles Markdown to a React Component using the markdown-parse parser -
posthtml-loaderLoads and transforms a HTML file using PostHTML -
handlebars-loaderCompiles Handlebars to HTML -
markup-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 DOM -
css-loaderLoads CSS file with resolved imports and returns CSS code -
less-loaderLoads and compiles a LESS file -
sass-loaderLoads and compiles a SASS/SCSS file -
postcss-loaderLoads and transforms a CSS/SSS file using PostCSS -
stylus-loaderLoads and compiles a Stylus file
Linting && Testing
-
mocha-loaderTests with mocha (Browser/NodeJS) -
eslint-loaderPreLoader for linting code using ESLint -
jshint-loaderPreLoader for linting code using JSHint -
jscs-loaderPreLoader for code style checking using JSCS -
coverjs-loaderPreLoader to determine the testing coverage using CoverJS
Frameworks
-
vue-loaderLoads and compiles Vue Components -
polymer-loaderProcess HTML & CSS with preprocessor of choice andrequire()Web Components like first-class modules -
angular2-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/