修复sfc的模板解析

pull/1/head
yutent 2023-02-23 00:00:10 +08:00
parent 03ace216e4
commit f5de90be2c
2 changed files with 4 additions and 2 deletions

View File

@ -90,6 +90,7 @@ export function parseJs(
return (
code
.replace(/\r\n/g, '\n')
.replace(
/import ([\w\W]*?) from (["'])(.*?)\2/g,
function (m, alias, q, name) {
@ -188,7 +189,7 @@ export function parseJs(
* @return <String> 返回转换后的js代码
*/
export function compileVue(file, imports, options = {}, isBuild) {
let code = (fs.cat(file) || '').toString()
let code = (fs.cat(file) || '').toString().replace(/\r\n/g, '\n')
let CACHE = options.CACHE || {}
let js = code.match(JS_EXP)
@ -251,6 +252,7 @@ document.adoptedStyleSheets.push(stylesheet)
*/
export function parseHtml(html, { page, imports, entry }, isBuild = false) {
return html
.replace(/\r\n/g, '\n')
.replace(
'</head>',
` <script>window.process = {env: {NODE_ENV: '${

View File

@ -6,7 +6,7 @@
export const JS_EXP = /<script[^>]*?>([\w\W]*?)<\/script>/
export const STYLE_EXP = /<style[^>]*?>([\w\W]*?)<\/style>/g
export const HTML_EXP = /<template[^>]*?>([\w\W]*?)<\/template>/
export const HTML_EXP = /<template[^>]*?>([\w\W]*?)\n<\/template>/
export const CSS_SHEET_EXP = /([@\w\.,#\-:>\+\~\|\(\)\[\]"'\=\s]+)\{/g