Skip to content

namehu/vue2-html-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vue logo

Vue2 HTML Loader

Exports HTML as string. HTML is minimized when the compiler demands.

This loader is similar to html-loader ,but the difference is this loader treat the html template as a string, It does not replace custom tags and attributes, and there is no intention to leave a space between the tags when removing spaces. it may cause an error in the vue $sloat processing.

Install

npm i -D vue2-html-loader

Usage

{
  test: /\.(html)$/,
  use: {
    loader: 'vue2-html-loader',
    options: {
      removeComments: true,
      removeWhiteSpace: true,
      removeNewline: true,
    }
  }
}
import template from 'path/to/your/template.html';

new Vue({
  template,
  ...otherOptions
});

Use Typescript

import template from 'path/to/your/template.html';

@Component({
  template,
})
export default class VueComponents extends Vue {
  ...others
}

Options Quick Reference

Most of the options are disabled by default.

Option Description Default
removeComments remove html comments true
removeWhiteSpace remove html whiteSpace true
removeNewline remove html newLine (actual \r\n) true

About

A webpack loader handle .html file for Vue2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published