summaryrefslogtreecommitdiff
path: root/webpack/module/rules/collapse-spaces.ts
blob: 734c735926d834e2f7c2fcc2ca7f6069d22484ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import * as fs from 'fs';
const minify = require('html-minifier').minify;

export default () => ({
	enforce: 'pre',
	test: /\.vue$/,
	exclude: /node_modules/,
	loader: 'string-replace-loader',
	query: {
		search: /^<template>([\s\S]+?)\r?\n<\/template>/,
		replace: html => {
			return minify(html, {
				collapseWhitespace: true,
				collapseInlineTagWhitespace: true,
				keepClosingSlash: true
			});
		}
	}
});