Browse Source

changes required for proper build

master
Marek Piasecki 2 years ago
parent
commit
5aaadef538
  1. 2
      readme.md
  2. 2
      site/src/main.imba
  3. 7
      src/vite-plugin.js

2
readme.md

@ -1,3 +1,3 @@
# pro-router-imba2 # pro-router-imba2
Integration of pro-router and Imba2. More information here http://imba-router.maniak.pro. Integration of pro-router and Imba2. More information here https://router.maniak.pro/imba2.

2
site/src/main.imba

@ -120,4 +120,4 @@ import './views/installation.imba'
import './views/usage.imba' import './views/usage.imba'
import './views/choosing-router-style.imba' import './views/choosing-router-style.imba'
imba.mount <App> if import.meta.env.MODE is 'development' imba.mount <App>

7
src/vite-plugin.js

@ -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

Loading…
Cancel
Save