Skip to main content

A simple module to extract html/script/style from a vuejs '.vue' file (can minimize/es2015 compliant js) ... just py2 or py3, NO nodejs !

Project description

vbuild

"Compile" your VUEJS component (*.vue) to standalone html/js/css ... python only (no need of nodejs). BTW it provides a js-minimizer (es2015 compliant code)

It's just an utility to extract HTML(template), SCRIPT and STYLE from a VUE/SFC component (*.vue). It's PURE python (py2 & py3 compatible), no nodejs ! It's fully unitested (100% !)

It won't replace webpack/nodejs/vue-cli, it fills the "Sometimes you have to work with the tools you have, not the ones you want." gap.

Available on pypi

import vbuild

sfc=vbuild.VBuild("mycompo.vue")
print( sfc.html )
print( sfc.script )
print( sfc.style )

or

import vbuild

ll=[]
ll.append( vbuild.VBuild("c1.vue") )
ll.append( vbuild.VBuild("c2.vue") )

s=sum(ll)

print( s.html )
print( s.script )
print( s.style )

You can use sass (using <style lang="scss"></style> or <style lang="sass"></style>) or less (using <style lang="less"></style>) in your styles. But you'll need to install pyscss or lesscpy

By the way, the module provide a js-minimizer (to generate ES2015 compliant) (thru on the clojure online service)

js="""async function  mymethod(...a) {
    var f=(...a) => {let b=12}
}
"""
min=vbuild.minimize(js)

Notes:

  • templates are converted to a <script type="text/x-template" id="XXX"></script> (not converted to JS)
  • A Minimal component needs the <template></template> tag only (specs)
  • You can use <style></style> and/or <style scoped></style> (as many as you want)
  • styles are minimized (remove comments and spaces)

Its main purpose is to let you use components (.vue files) in your vuejs app, without a full nodejs stack. It's up to you to create your generator, to extract the things, and create your "index.html" file. It's a 5 lines of python code; example:

import vbuild,glob
r=sum([vbuild.VBuild(i) for i in glob.glob("*.vue")+glob.glob("*/*.vue")])
buf=readYourTemplate("index.tpl") # should contains a tag "<!-- HERE -->" that would be substituted
buf=buf.replace("<!-- HERE -->",str(r))
writeYourTemplate("index.html",buf)

(a real example of rendering vue/sfc components, using vbuild and the marvelous wuy)

Hope it could help ...

TODO:

  • more utilities
  • and docs !

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vbuild-0.4.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

vbuild-0.4.4-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file vbuild-0.4.4.tar.gz.

File metadata

  • Download URL: vbuild-0.4.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for vbuild-0.4.4.tar.gz
Algorithm Hash digest
SHA256 dd3c792aa7efe1db199d80b34969071dce76b1472aa56083daee6726b06bfbbb
MD5 ccb17ca35f7f73028545327b8d5b5eda
BLAKE2b-256 7697f2883fc2f0743b0d6da91a67f6eac92f768912aea1ff56faf1e2fddb3d3f

See more details on using hashes here.

File details

Details for the file vbuild-0.4.4-py2.py3-none-any.whl.

File metadata

  • Download URL: vbuild-0.4.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for vbuild-0.4.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ca81b61845c934a89842c8a5f56f707ed1b3c7c51c415294fd8ee4b69501e3bf
MD5 8011abfb40ef8b3a0d18f3220b7c8eab
BLAKE2b-256 5fe31092809d81d6f57b092cbbe75aace8446b2264733c1f87690e37af16afa9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page