# vue-extend-template-loader

> A loader for extending vue sfc templates alongside simple extension

Latest version **0.0.1** (published 2019-02-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-extend-template-loader
pnpm add vue-extend-template-loader
yarn add vue-extend-template-loader
bun add vue-extend-template-loader
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-02-27 |
| First published | 2019-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Paul Rukavishnikov |
| Maintainers | crysknight |
| Keywords | vue, loader, webpack, sfc |

## Links

- npm: https://www.npmjs.com/package/vue-extend-template-loader
- Repository: https://github.com/Crysknight/vue-extend-template-loader
- Homepage: https://github.com/Crysknight/vue-extend-template-loader#readme
- Issues: https://github.com/Crysknight/vue-extend-template-loader/issues
- npm.io page: https://npm.io/package/vue-extend-template-loader

## Dependencies (1)

- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.2

## 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

- 0.0.1 (latest) — 2019-02-27

## README

# vue-extend-template-loader
A loader for extending vue sfc templates alongside simple extension

## How to connect

```
npm i -D vue-extend-template-loader
```

#### webpack.config.js - configureWebpack
```
module.exports = {
    configureWebpack: {
        module: {
            rules: [
                {
                    test: /\.vue$/,
                    enforce: 'pre',
                    loader: 'vue-extend-template-loader'
                }
            ]
        }
    }
};
```

#### webpack.config.js - chainWebpack
```
module.exports = {
    chainWebpack: config => {
        config.module
            .rule('extend-template')
            .test(/\.vue$/)
            .pre()
            .use()
            .loader('vue-extend-template-loader')
            .end()
            .end();
    }
};
```

## Supported operations (`mode="operationName"` in extender)
- append, prepend - appends or prepends markup to the queried node
- delete, remove - deletes node
- replace - replaces queried node with specified markup
- after, before - inserts markup before or after queried node

## Usage example:

### Base Component
```
<template>
    <div class="test-1">
        <div class="hello">Hello</div>
        <div class="hi">Hi</div>
    </div>
</template>

<script>
export default {
    name: 'Test1'
};
</script>
```

### Extender Component
*Don't forget to specify `type="extend"` in your template tag since without it loader will NOT process your template, 
and Vue will then completely replace the source template with it (breaking it ofc)*
```
<template type="extend">
    <extenders>
        <!-- Attribute query is similar to css selector -->
        <extender query=".test-1" mode="append">
            <div class="howdy">Howdy!</div>
        </extender>
        <extender query=".hi" mode="delete" />
    </extenders>
</template>

<script>
import Test1 from 'src/test_1';

export default {
    name: 'Test2',
    extends: Test1,
    computed: {
        dizzy() {
            return true;
        }
    }
};
</script>
```

### Result component
```
<template>
    <div class="test-1">
        <div class="hello">Hello</div>
        <div class="howdy">Howdy!</div>
    </div>
</template>

<script>
import Test1 from './test_1';

export default {
    name: 'Test2',
    extends: Test1,
    computed: {
        dizzy() {
            return true;
        }
    }
};
</script>
```

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