https://github.com/xipasduarte/no-emit-webpack-plugin
Stop an asset from being emitted by the webpack compiler.
https://github.com/xipasduarte/no-emit-webpack-plugin
webpack webpack-plugin webpack4 webpack5
Last synced: 4 months ago
JSON representation
Stop an asset from being emitted by the webpack compiler.
- Host: GitHub
- URL: https://github.com/xipasduarte/no-emit-webpack-plugin
- Owner: xipasduarte
- License: mit
- Created: 2018-01-07T00:52:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:08:19.000Z (over 3 years ago)
- Last Synced: 2025-07-03T16:14:35.282Z (12 months ago)
- Topics: webpack, webpack-plugin, webpack4, webpack5
- Language: JavaScript
- Homepage:
- Size: 584 KB
- Stars: 5
- Watchers: 1
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# No Emit WebPack Plugin
[](https://travis-ci.org/xipasduarte/no-emit-webpack-plugin)
Stop an asset from being emitted by the webpack compiler.
## Install
**Webpack 5**
```bash
npm install --save-dev no-emit-webpack-plugin
```
```bash
yarn add -D no-emit-webpack-plugin
```
**Webpack 4**
```bash
npm install --save-dev no-emit-webpack-plugin@3.0.0
```
```bash
yarn add -D no-emit-webpack-plugin@3.0.0
```
## Options
> :warning: By default, if you don't supply any options the bundles for all entry points will be removed.
```js
new NoEmitPlugin(options: string | array)
```
* If a `string` is supplied only one asset bundle will be removed.
* The array must be composed of elements with type `string` that will be matched with asset bundle names, and removed.
## Usage
This plugin is most useful when you are bundling assets that start from file types other than JavaScript, like styles for instance. With it you can remove the resulting file defined in the `output` option of your `webpack.config.js`.
Below is an example on how to remove the `style.js` file from the emitted assets. We'll use the [Mini CSS Extract Plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to generate the CSS asset.
```js
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const NoEmitPlugin = require('no-emit-webpack-plugin');
module.exports = {
entry: {
style: path.resolve(__dirname, 'style.css'),
main: path.resolve(__dirname, 'main.js'),
},
module: {
rules: [{
test: /\.css/iu,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
],
}],
},
plugins: [
new MiniCssExtractPlugin(),
new NoEmitPlugin('style.js'),
],
}
```
## License
MIT © [Pedro Duarte](https://github.com/xipasduarte)