Summary of commonly used loaders and plugins for webpack project practical summary
Others
2021-03-22 00:32:47
views: null
One, commonly used loader
JavaScript
Related, as follows:
babel-loader
: The ES6
converted ES5
;
script-loader
: May be specified module JavaScript
file into a string by pure eval
implementation;
exports-loader
: You can export the specified object, for example window.Zepto
;
ts-loader
: The TypeScript
converted JavaScript
;
imports-loader
: Add any of the three parties object to the window
object.
The style is related, as shown below:
style-loader
: The CSS
code into the JavaScript
by DOM
operation to load CSS
;
css-loader
: Load CSS
, support modularization, compression, file import and other features;
postcss-loader
: CSS
Post-processor postcss
of loader
;
less-loader
Of: less
converting code into CSS
the code;
sass-loader
Of: SCSS/SASS
converting code into CSS
the code;
fast-sass-loader
: Parallel processing SCSS/SASS
file, than Sass-loader
faster 5~10
times loader
;
stylus-loader
Of: Stylus
converting code into CSS
the code;
mini-css-extract-plugin
Of loader
: the CSS
styles extract the contents to CSS
a file.
Static resources are related, as shown below:
raw-loader
: Load the content of the text file into the code;
file-loader
: Output to a file folder in the code by a relative URL
reference to the output file;
url-loader
: And file-loader
the like, but can in case of very small file in base64
a manner to inject the contents of the file to the code;
html-loader
: HTML
Grammar loader
, can be processed HTML
in the picture, CSS
and so on;
svg-url-loader
: The compressed SVG
content is injected into the code;
markdown-loader
: To Markdown
convert the file into HTML
;
ejs-loader
: The EJS
stencil compiled into function return;
pug-loader
: To Pug
convert into a template JavaScript
function returns;
image-webpack-loader
: Load and compress image files;
csv-loader
: Load the csv
file contents;
xml-loader
: Load the xml
contents of the file.
Engineering related, as shown below:
eslint-loader
: By ESLint
checking JavaScript
codes;
tslint-loader
: By TSLint
checking TypeScript
codes;
mocha-loader
: Load Mocha
test code.
Others, as follows:
vue-loader
: Load Vue.js
single-file assembly.
Two, commonly used plugin
Webpack
The built-in plugins are as follows:
webpack.DefinePlugin
: Define global constant plug-ins;
webpack.EnvironmentPlugin
: Define the environment variable plug-in;
webpack.BannerPlugin
: Add copyright notes etc. to the code;
webpack.DllPlugin
: Using DLL
ideas to speed up the compilation speed of the plug;
webpack.HashedModuleIdsPlugin
: You can modify the file Hash
plug-in algorithms;
webpack.optimize.SplitChunksPlugin
: Code splitting optimization plug-in;
webpack.HotModuleReplacementPlugin
: Turn on the module hot replacement function, by monitoring file changes and automatically loading the modified files to reduce the annoying browser manual reloading;
webpack.ProgressPlugin
: Build progress plugin;
webpack.ProvidePlugin
: Auto-loading modules, such as occurs $
the load jQuery
and other common library;
webpack.IgnorePlugin
: Used to ignore some files
The non-built-in plug-ins are as follows:
mini-css-extract-plugin
: CSS
File is extracted, and is constructed in a production environment can be used to optimize CSS
the file size;
optimize-css-assets-webpack-plugin
: Compressed CSS
files;
clean-webpack-plugin
: Clean up the specified contents of the specified directory before compiling;
html-webpack-plugin
: html
Plug-in, you can JavaScript
generate a template file HTML
;
preload-webpack-plugin
: html-webpack-plugin
Plugins page to add <link rel="preload">
resources;
i18n-webpack-plugin
: Help web pages to be internationalized plug-ins;
webpack-manifest-plugin
: Generate Webpack
packaged plugin file list;
html-webpack-inline-source-plugin
: In HTML
the inline package out of resources;
webpack-bundle-analyzer
: webpack bundle
Analysis plug-in;
copy-webpack-plugin
Copy file copy plugin to a specified folder: output
folders for the packing line;
terser-webpack-plugin
: JavaScript
Code compression plug-in that is compatible with ES6
the syntax, it is recommended to use this plug-in, rather than uglifyjs;
serviceworker-webpack-plugin
: Generating PWA service worker
plug;
hard-source-webpack-plugin
: Improve the speed of non-first compilation through caching;
friendly-errors-webpack-plugin
: Reducing Webpack
useless construct log
;
stylelint-webpack-plugin
: StyleLint
The plugin.
Origin blog.csdn.net/weixin_42614080/article/details/110609210