Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drylikov/no_emit_webpack_plugin
Stop an asset from being Emitted by the WebPack compiler.
https://github.com/drylikov/no_emit_webpack_plugin
Last synced: 8 days ago
JSON representation
Stop an asset from being Emitted by the WebPack compiler.
- Host: GitHub
- URL: https://github.com/drylikov/no_emit_webpack_plugin
- Owner: drylikov
- License: mit
- Created: 2024-08-05T03:22:42.000Z (3 months ago)
- Default Branch: drylikov
- Last Pushed: 2024-08-05T03:28:37.000Z (3 months ago)
- Last Synced: 2024-08-05T04:39:34.376Z (3 months ago)
- Language: JavaScript
- Size: 65.4 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 [email protected]
``````bash
yarn add -D [email protected]
```## 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 ExtractTextPlugin = require('extract-text-webpack-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()],
}
```