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 |
|
16 | A webpack loader that returns an empty module.
|
17 |
|
18 | One use for this loader is to silence modules imported by a dependency. Say, for
|
19 | example, your project relies on an ES6 library that imports a polyfill you don't
|
20 | need, so removing it will cause no loss in functionality.
|
21 |
|
22 | ## Getting Started
|
23 |
|
24 | To begin, you'll need to install `null-loader`:
|
25 |
|
26 | ```console
|
27 | $ npm install null-loader --save-dev
|
28 | ```
|
29 |
|
30 | Then add the loader to your `webpack` config. For example:
|
31 |
|
32 | ```js
|
33 | // webpack.config.js
|
34 | const path = require('path');
|
35 |
|
36 | module.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 |
|
50 | And run `webpack` via your preferred method.
|
51 |
|
52 | ## Contributing
|
53 |
|
54 | Please 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
|