Skip to main content

A django-compressor filter to compile .vue files using rollup

Project description

django-vue-rollup

A django-compressor filter to compile .vue files using rollup.

Installation

Install django-compressor in your django project.

During installation, django-vue-rollup will call npm to install necessary packages, so make sure you have npm installed.

In order to avoid any possible conflicts, the npm packages will installed into a local node prefix inside of django-vue-rollup's package directory.

Once you have ensured that npm is available, you can install django-vue-rollup:

pip install django-vue-rollup

Finally, add the provided Vue Compiler to your COMPRESS_PRECOMPILERS setting:

COMPRESS_PRECOMPILERS = (
    ('text/vue', 'django_vue_rollup.VueCompiler'),
)

To include and compile .vue files, you can use a <script> tag with the type text/vue, for example:

{% load compress %}

{% compress js %}
    <script type="text/vue" src="{% static 'myapp/js/my-vue-component.vue' %}"></script>
{% endcompress %}

The output format of the compiled vue file will be IIFE. The export name will be automatically generated by converting your input file name to camel case. For example, the export name in the Example above would be MyVueComponent. The default export can be accessed using MyVueComponent.default, other named exports by replacing default with their respective names.

Disclaimer

I am a Python and Django expert, not a Javascript expert and i have developed this python package based on what exactly i needed for my application, because to my surprise, i couldn't find a solution for this that didn't ask you to run a second javascript-based server.

If there is a feature you're missing or you feel that something about the way this code handles things is not how it should be done, please feel very welcome to submit an issue or a pull request!

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

django-vue-rollup-0.1.2.tar.gz (20.7 kB view details)

Uploaded Source

File details

Details for the file django-vue-rollup-0.1.2.tar.gz.

File metadata

  • Download URL: django-vue-rollup-0.1.2.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6

File hashes

Hashes for django-vue-rollup-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2380a5c0a5ef25504cc16ca8584ad5e7ee46d03a5788be877b949ce542a2bf32
MD5 da077abf9224e670184309de762f6fb4
BLAKE2b-256 2ed996a4007cbe9bf171514747fb580eab941b6ac40b8f3748e0fecdc1ceeff2

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page