vbuild - Vue Single File Component Parser

0.8.2 · active · verified Fri Apr 17

vbuild is a Python library (v0.8.2) designed to extract HTML, JavaScript, and CSS from Vue.js `.vue` single-file components. Its primary advantage is operating without a Node.js environment, making it suitable for Python-only backends. It supports minification and targets ES2015-compliant JavaScript. The project is currently in active maintenance with infrequent updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate VBuild with a Vue SFC string and extract its `html`, `script`, and `style` components. It also shows basic minification options.

from vbuild.vbuild import VBuild

vue_sfc_content = """
<template>
  <div id="app">
    <h1>Hello {{ name }}</h1>
    <p>Message: {{ msg }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: 'Registry',
      msg: 'This is a vbuild example'
    }
  }
}
</script>

<style scoped>
#app {
  font-family: Arial, sans-serif;
  color: #333;
}
h1 {
  color: #007bff;
}
</style>
"""

vb = VBuild(vue_sfc_content)

print("--- HTML ---")
print(vb.html)
print("\n--- Script ---")
print(vb.script)
print("\n--- Style ---")
print(vb.style)

# Example with minification
vb_minified = VBuild(vue_sfc_content, minify=True, minify_js=True)
print("\n--- Minified Script (first 100 chars) ---")
print(vb_minified.script[:100])

view raw JSON →