Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Commit 79b1d95

Browse files
committed
deindent code blocks
1 parent e23bab2 commit 79b1d95

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

lib/compiler.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var rewriteTemplate = require('./template-rewriter')
1010
var validateTemplate = require('vue-template-validator')
1111
var chalk = require('chalk')
1212
var assign = require('object-assign')
13+
var deindent = require('de-indent')
1314
var Emitter = require('events').EventEmitter
1415

1516
// production minifiers
@@ -208,6 +209,7 @@ function isScoped (node) {
208209

209210
function processTemplate (node, filePath, id, hasScopedStyle, fullSource) {
210211
var template = checkSrc(node, filePath) || parse5.serialize(node.content)
212+
template = deindent(template)
211213
var lang = checkLang(node)
212214
if (!lang) {
213215
var warnings = validateTemplate(node.content, fullSource)
@@ -246,6 +248,7 @@ function processTemplate (node, filePath, id, hasScopedStyle, fullSource) {
246248
function processStyle (node, filePath, id) {
247249
var style = checkSrc(node, filePath) || parse5.serialize(node)
248250
var lang = checkLang(node)
251+
style = deindent(style)
249252
return compileAsPromise('style', style, lang, filePath)
250253
.then(function (res) {
251254
return rewriteStyle(id, res.source, isScoped(node))
@@ -271,6 +274,7 @@ function processScript (node, filePath, content) {
271274
var before = padContent(content.slice(0, location))
272275
script = before + script
273276
}
277+
script = deindent(script)
274278
return compileAsPromise('script', script, lang, filePath)
275279
}
276280

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"autoprefixer": "^6.0.3",
2525
"chalk": "^1.1.1",
2626
"cssnano": "^3.3.2",
27+
"de-indent": "^1.0.2",
2728
"es6-promise": "^3.0.2",
2829
"hash-sum": "^1.0.2",
2930
"html-minifier": "^1.0.0",

test/expects/custom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
console.log('ok')
2+
console.log('ok')
33

44
if (module.exports.__esModule) module.exports = module.exports.default

test/expects/non-minified.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
var __vueify_style__ = require("vueify-insert-css").insert("\n html {\n font-size: 20px;\n }\n")
2-
;(typeof module.exports === "function"? module.exports.options: module.exports).template = "\n <h1 :id=\"id\" @click=\"hi\">hello</h1>\n"
1+
var __vueify_style__ = require("vueify-insert-css").insert("\nhtml {\n font-size: 20px;\n}\n")
2+
;(typeof module.exports === "function"? module.exports.options: module.exports).template = "\n<h1 :id=\"id\" @click=\"hi\">hello</h1>\n"

0 commit comments

Comments
 (0)