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.
npm i -D vue2-html-loader
{
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
});
import template from 'path/to/your/template.html';
@Component({
template,
})
export default class VueComponents extends Vue {
...others
}
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 |