# join-file-content-plugin

> Prepend or append file to a target file while webpack running

Latest version **1.0.3** (published 2019-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install join-file-content-plugin
pnpm add join-file-content-plugin
yarn add join-file-content-plugin
bun add join-file-content-plugin
```

## 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.0.3 |
| Published | 2019-10-19 |
| First published | 2019-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | hz |
| Maintainers | hzsrc |

## Links

- npm: https://www.npmjs.com/package/join-file-content-plugin
- Homepage: https://github.com/hzsrc/join-file-content-plugin#readme
- Issues: https://github.com/hzsrc/join-file-content-plugin/issues
- npm.io page: https://npm.io/package/join-file-content-plugin

## Dependencies (1)

- [throttle-debounce](https://npm.io/package/throttle-debounce.md) ^1.0.1

## Recent versions

- 1.0.3 (latest) — 2019-10-19
- 1.0.2 — 2019-10-19
- 1.0.1 — 2019-10-10
- 1.0.0 — 2019-10-10

## README

## join-file-content-plugin
A webpack plugin, auto prepend or append file to a target file while webpack starting.    
When the prepending or appending file changed, do this again.

#### sapmle
For `element-ui`, we need to prepend some customized variables before the `element-ui` variable [scss] file `node_modules/element-theme-chalk/src/common/var.scss` (`sass-loader` can do this but does't support file).    

We can set the customized variables in a file `theme-changed.scss`, and use this plugin to prepend this file to the `var.scss` of element-ui.    

Config webpack like this:

````js
// webpack-config.js
const JoinFileContentPlugin = require('join-file-content-plugin')

module.exports = {
    /* other configs here */
    plugins:[
        /* other plugins here */
        new JoinFileContentPlugin({
            file: 'node_modules/element-theme-chalk/src/common/var.scss', // target file for changing.
            prependFile: 'src/css/element-theme/theme-changed.scss', // file for prepending before the target file. optional.
            // appendFile: '', // file for appending to the target file. optional.
            // cwd: '.', // relative to this path. optional.
            // encoding: 'utf-8', // text encoding. optional.
            // watch: process.env.NODE_ENV === 'development', // watch file changing. optional
        }),
    ]
}
````

After we change the variables in `theme-changed.scss`, webpack will hot-reload it for preview.

[Here](https://github.com/hzsrc/vue-element-ui-scaffold-webpack4) is the whole project for this sample.

---
_Source: https://npm.io/package/join-file-content-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
