UNPKG

2.21 kBMarkdownView Raw
1<div align="center">
2 <a href="https://github.com/webpack/webpack">
3 <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
4 </a>
5</div>
6
7[![npm][npm]][npm-url]
8[![node][node]][node-url]
9[![deps][deps]][deps-url]
10[![tests][tests]][tests-url]
11[![chat][chat]][chat-url]
12[![size][size]][size-url]
13
14# null-loader
15
16A webpack loader that returns an empty module.
17
18One use for this loader is to silence modules imported by a dependency. Say, for
19example, your project relies on an ES6 library that imports a polyfill you don't
20need, so removing it will cause no loss in functionality.
21
22## Getting Started
23
24To begin, you'll need to install `null-loader`:
25
26```console
27$ npm install null-loader --save-dev
28```
29
30Then add the loader to your `webpack` config. For example:
31
32```js
33// webpack.config.js
34const path = require('path');
35
36module.exports = {
37 module: {
38 rules: [
39 {
40 // Test for a polyfill (or any file) and it won't be included in your
41 // bundle
42 test: path.resolve(__dirname, 'node_modules/library/polyfill.js'),
43 use: 'null-loader',
44 },
45 ],
46 },
47};
48```
49
50And run `webpack` via your preferred method.
51
52## Contributing
53
54Please take a moment to read our contributing guidelines if you haven't yet done so.
55
56[CONTRIBUTING](./.github/CONTRIBUTING.md)
57
58## License
59
60[MIT](./LICENSE)
61
62[npm]: https://img.shields.io/npm/v/null-loader.svg
63[npm-url]: https://npmjs.com/package/null-loader
64[node]: https://img.shields.io/node/v/null-loader.svg
65[node-url]: https://nodejs.org
66[deps]: https://david-dm.org/webpack-contrib/null-loader.svg
67[deps-url]: https://david-dm.org/webpack-contrib/null-loader
68[tests]: https://img.shields.io/circleci/project/github/webpack-contrib/null-loader.svg
69[tests-url]: https://circleci.com/gh/webpack-contrib/null-loader
70[cover]: https://codecov.io/gh/webpack-contrib/null-loader/branch/master/graph/badge.svg
71[cover-url]: https://codecov.io/gh/webpack-contrib/null-loader
72[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg
73[chat-url]: https://gitter.im/webpack/webpack
74[size]: https://packagephobia.now.sh/badge?p=null-loader
75[size-url]: https://packagephobia.now.sh/result?p=null-loader