Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/fergaldoyle/vue-template-compiler-loader
- Owner: fergaldoyle
- License: mit
- Created: 2016-08-20T21:19:26.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-24T10:54:03.000Z (almost 8 years ago)
- Last Synced: 2024-10-12T08:49:00.905Z (about 1 month ago)
- Topics: html-templates, vuejs2, webpack, webpack-loader
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 26
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 () {}
}
```