Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/privatenumber/code-inject-loader

Inject code to certain files
https://github.com/privatenumber/code-inject-loader

append code inject loader prepend transform webpack

Last synced: 18 days ago
JSON representation

Inject code to certain files

Awesome Lists containing this project

README

        

# code-inject-loader
> Inject code to certain files

## How to use
Add as a loader rule to configure which files the loader should inject code into.

webpack.config.js
```
moule.exports = {
...,

module: {
rules: [
{
test: /src/,
loader: 'code-inject-loader',
options: {
prepend: `console.log('Hello Im in every file');`
},
},
...
]
},

...
}
```

### Options
- *prepend * Add code to the beginning of the file
- *append * Add code to the bottom of the file
- *transform(source) * Function to make changes to the source code of the file