Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit ea1459a

Browse files
mrkishiznck
authored andcommitted
feat: enable htmlMinifier.conservativeCollapse by default (#117)
* Enable `htmlMinifier.conservativeCollapse` * fix: trim white spaces from template code * refact: adjust test cases to `conservativeCollapse` option
1 parent 42122ce commit ea1459a

File tree

8 files changed

+9
-8
lines changed

8 files changed

+9
-8
lines changed

src/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default {
1717
caseSensitive: true,
1818
customAttrSurround: [[/@/, new RegExp('')], [/:/, new RegExp('')]],
1919
collapseWhitespace: true,
20+
conservativeCollapse: true,
2021
removeComments: true
2122
},
2223

src/vueTransform.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function processTemplate (source, id, content, options, nodes, modules) {
5252
debug(`Process template: ${id}`)
5353

5454
const extras = { modules, id, lang: source.attrs.lang }
55-
const code = deIndent(source.code)
55+
const code = deIndent(source.code).trim()
5656
const template = await (
5757
options.disableCssModuleStaticReplacement !== true
5858
? templateProcessor(code, extras, options)

test/expects/basic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var evens = [2,4,6,8];
22
var odds = evens.map(v => v + 1);
3-
var basic = { template: "<h1 :id=\"id\" @click=\"hi\">hello</h1><input type=\"text\">",
3+
var basic = { template: "<h1 :id=\"id\" @click=\"hi\">hello</h1> <input type=\"text\">",
44
data() {
55
return odds
66
}

test/expects/imports.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
var evens = [2,4,6,8];
22
var odds = evens.map(v => v + 1);
3-
var Basic = { template: "<h1 :id=\"id\" @click=\"hi\">hello</h1><input type=\"text\">",
3+
var Basic = { template: "<h1 :id=\"id\" @click=\"hi\">hello</h1> <input type=\"text\">",
44
data() {
55
return odds
66
}
77
};
88

9-
var imports = { template: "<main><basic></basic></main>",
9+
var imports = { template: "<main> <basic></basic> </main>",
1010
components: {
1111
Basic
1212
}

test/expects/slot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var TableComponent = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('table',[_c('tr',[_c('td',[_vm._t("default")],2)])])},staticRenderFns: [],};
22

3-
var slot = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('table-component',[_vm._v("Hello! World")])},staticRenderFns: [],
3+
var slot = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('table-component',[_vm._v(" Hello! World ")])},staticRenderFns: [],
44
components: { TableComponent },
55
};
66

test/expects/style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var evens = [2,4,6,8];
22
var odds = evens.map(v => v + 1);
3-
var style = { template: "<h1 :id=\"id\" @click=\"hi\">hello</h1><input type=\"text\">",
3+
var style = { template: "<h1 :id=\"id\" @click=\"hi\">hello</h1> <input type=\"text\">",
44
data() {
55
return odds
66
}

test/expects/typescript-export-obj.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var app = {
22
};
33

4-
var __$app = Object.assign(app, { template: "<h1 :id=\"id\" @click=\"hi\">hello</h1><input type=\"text\">",});
4+
var __$app = Object.assign(app, { template: "<h1 :id=\"id\" @click=\"hi\"> hello</h1> <input type=\"text\">",});
55
__$app.prototype = app.prototype;
66

77
export default __$app;

test/expects/typescript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var component = { template: "<h1 :id=\"id\" @click=\"hi\">hello</h1><input type=\"text\">",
1+
var component = { template: "<h1 :id=\"id\" @click=\"hi\"> hello</h1> <input type=\"text\">",
22
data: function () { return ({
33
hello: 'world!'
44
}); },

0 commit comments

Comments
 (0)