# webpack-inject-loader

> inject chuncks of code from js files

Latest version **1.5.0** (published 2016-04-01) · 0 weekly downloads

## Install

```sh
npm install webpack-inject-loader
pnpm add webpack-inject-loader
yarn add webpack-inject-loader
bun add webpack-inject-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2016-04-01 |
| First published | 2016-03-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Michael Wheeler |
| Maintainers | echo-peak |
| Keywords | webpack, loader |

## Links

- npm: https://www.npmjs.com/package/webpack-inject-loader
- Repository: https://github.com/Echo-Peak/webpack-inject-loader
- Issues: https://github.com/Echo-Peak/webpack-inject-loader/issues
- npm.io page: https://npm.io/package/webpack-inject-loader

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.5.0 (latest) — 2016-04-01
- 1.0.2 — 2016-03-29
- 1.0.1 — 2016-03-29
- 1.0.0 — 2016-03-29

## README

# webpack-inject-loader
Installation
-------------
```
npm install webpack-inject-loader
```
Description
-------------
have a large function that cant be easily modulelize into seprate functions?
useful if you have hard to reason code that needs to be split up into chunks of code

inject code blocks into file without haveing webpack to put small chuncks of code into functions/modules thus increasing output performance

Usage
-------------
Options:
```
{
	console:{
		enabled:<Boolean: Default = true>
		color:<red ,green ,yellow, purple,blue,lightBlue : Default = lightBlue>
	},
	regexp:{
		startWith:<String : Default = @inject> *this will be transformed into a regexp,
		safe:<Boolean : Default = true> *always start regexp with // or not
	}
}
```
> **in-some-file.js**


###before
```

function getRandomHexColor(){
	var hexabet = '0123456789abcdef';
	var hex = '#';
	var hexLength = 6;
	while(hexLength--){
	hex += hexabet[Math.floor(Math.random()*16)];
	//...more code
}


return hex
}
```
###after
```


function getRandomHexColor(){
	var hexabet = '0123456789abcdef';
	var hex = '#';
	var hexLength = 6;
	//@inject <../some/path/to/file>.js

return hex
}
```
###webpack
```
var optionalSettings = {
	enable:true,
	console:{
		enable:true,
		color:'red'
	},
	regex:{
		startWith:'STARTwithThis',
		safe:true
	}
}

module.exports = {
	entry:'path',
	module:{
		loaders:[
			{
				test:/\.js/,
				loaders:[
				'webpack-inject-loader?'+JSON.stringify(optionalSettings ),
				'babel'
				]
			}
		]
	}

}
```

---
_Source: https://npm.io/package/webpack-inject-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
