Giter Site home page Giter Site logo

jameskeane / django-vue-rollup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codingcatgirl/django-vue-rollup

0.0 1.0 0.0 12 KB

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

License: Apache License 2.0

JavaScript 6.43% Python 93.57%

django-vue-rollup's Introduction

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!

django-vue-rollup's People

Contributors

codingcatgirl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.