@altipla/vue-template-compiler-loader
v1.0.0
Published
Webpack loader to pre-compile Vue 2.0 templates. - Allows custom compiler options.
Downloads
5
Maintainers
Readme
vue-template-compiler-loader
This is a copy of the official vue-template-compiler-loader
that allows custom compiler options.
See this repo for the original source code: https://github.com/fergaldoyle/vue-template-compiler-loader
Install
npm i @altipla/vue-template-compiler-loader --save-dev
You will also need the peer dependency of vue-template-compiler
in the same version as Vue. All the compiler versions work with the latest release of this package.
npm i vue-template-compiler --save-dev
Configuration
Add this configuration to your module.loaders
inside webpack.config.js
:
{
test: /\.vhtml$/,
loader: '@altipla/vue-template-compiler',
options: {
compilerOptions: {
whitespace: 'preserve',
},
},
},
You can use any option of the compiler available in the documentation.
Usage
Split the template and the script in two files and you can import it from the component:
import Vue from 'vue';
import template from './my-component.vhtml';
Vue.component('my-component', {
...template,
mounted () {
// ...
},
});