Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/fergaldoyle/vue-template-compiler-loader

Webpack loader to pre-compile Vue 2.0 templates
https://github.com/fergaldoyle/vue-template-compiler-loader

html-templates vuejs2 webpack webpack-loader

Last synced: 18 days ago
JSON representation

Webpack loader to pre-compile Vue 2.0 templates

Awesome Lists containing this project

README

        

# vue-template-compiler-loader

Webpack loader to pre-compile Vue 2.0 templates.

`npm i vue-template-compiler-loader --save-dev`

### Webpack config
To `module.loaders` add:

`{ test: /\.html$/, loader: 'vue-template-compiler' }`

### Usage

`import template from './template.html'`

`template` will be an object

```javascript
{
render: Function,
staticRenderFns: Array
}
```

Set `render` and `staticRenderFns` properties on a component e.g:

```javascript
// manually
import template from './template.html'

export const myComponent = {
name: 'myComponent',
render: template.render,
staticRenderFns: template.staticRenderFns,
mounted () {}
}

// mixin
import template from './template.html'

export const myComponent = {
name: 'myComponent',
mixins: [template],
mounted () {}
}

// stage2 object spread
import template from './template.html'

export const myComponent = {
name: 'myComponent',
...template,
mounted () {}
}
```