|
@ -9,16 +9,19 @@ let pathViews = {} // path: [view] |
|
|
function duplicate(obj){ return JSON.parse(JSON.stringify(obj)) } |
|
|
function duplicate(obj){ return JSON.parse(JSON.stringify(obj)) } |
|
|
function without(el, arr) { return arr.filter(function(e){ if(e != el) { return e } }) } |
|
|
function without(el, arr) { return arr.filter(function(e){ if(e != el) { return e } }) } |
|
|
|
|
|
|
|
|
|
|
|
let config |
|
|
module.exports = function proRouterViews() { |
|
|
module.exports = function proRouterViews() { |
|
|
return { |
|
|
return { |
|
|
name: 'pro-router-views', |
|
|
name: 'pro-router-views', |
|
|
transformIndexHtml(html) { |
|
|
|
|
|
return html.replace('<head>', '<head><script>window.Views=[];</script>') |
|
|
configResolved(resolvedConfig) { |
|
|
|
|
|
config = resolvedConfig |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
transform: { |
|
|
transform: { |
|
|
order: 'pre', |
|
|
order: 'pre', |
|
|
handler(src, id) { |
|
|
handler(src, id) { |
|
|
|
|
|
if (config.command !== 'serve'){ return src } |
|
|
if (/\.imba$/.test(id)) { |
|
|
if (/\.imba$/.test(id)) { |
|
|
let modified = false |
|
|
let modified = false |
|
|
let viewRegExp = /tag view-((\w|\S)+)( |\n)/g |
|
|
let viewRegExp = /tag view-((\w|\S)+)( |\n)/g |
|
|