Coder Social home page Coder Social logo

Comments (7)

musicformellons avatar musicformellons commented on August 19, 2024

The js (render_bundle) needs somehow to come after the vue tag reference in the html file!

This works:

{% load staticfiles %}
{% load render_bundle from webpack_loader %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Webpack Sample Project</title>
</head>
<body>

<h3>[[ message ]]</h3>
kiekeboe

{% render_bundle 'main' %}
</body>
</html>

from django-webpack-loader.

darklow avatar darklow commented on August 19, 2024

@musicformellons Could you please share your config of webpack for vuejs?
I am struggling putting together Django and VueJS.
Thank you.

from django-webpack-loader.

musicformellons avatar musicformellons commented on August 19, 2024

I jumped the fence into javascript land... No more Django... Sorry... Good luck.

from django-webpack-loader.

rawberg avatar rawberg commented on August 19, 2024

I'm using Vue.js with Django Webpack loader without problems. Here is my index.html template.

{% load render_bundle from webpack_loader %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>App Title</title>
        {% render_bundle 'public' 'css' %}
    </head>
    <body>
        <div id="stx-viewport"></div>
        {% render_bundle 'public' 'js'%}
    </body>
</html>

from django-webpack-loader.

darklow avatar darklow commented on August 19, 2024

@rawberg I don't have a problem with template part, these few tags are easy.
I was wondering about webpack config with hot reload, could you please share that? Thanks.

from django-webpack-loader.

rawberg avatar rawberg commented on August 19, 2024

I haven't gone through the trouble of setting up hot reload but good old fashioned refresh seems to work pretty well with this setup.

module: {
        loaders: [
            {
                test: /\.vue$/,
                loader: 'vue'
            },
            {
                test: /\.js$/,
                loader: 'babel',
                exclude: /node_modules/
            },
            {
                test: /\.json$/,
                loader: 'json',
                exclude: /node_modules/
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract({fallbackLoader: "style-loader", loader: "css-loader"}),
                exclude: /node_modules/
            },
            {
                test: /\.less$/,
                loader: ExtractTextPlugin.extract({fallbackLoader: "style-loader", loader: "css-loader!less-loader"})
            },
            // handles all references to these files in JS or CSS, use copy webpack plugin
            // for images references in HTML or anywhere else
            {
                test: /\.(png|jpg|gif|svg|gif)$/,
                loader: 'file-loader',
                query: {
                    name: 'img/[name]-[hash].[ext]'
                }
            },
            {
                test: /\.(ttf|eot|woff|woff2)$/,
                loader: 'file-loader',
                query: {
                    name: 'font/[name]-[hash].[ext]'
                }
            },
            {
                test: /\.(txt|ico)$/,
                loader: 'static-loader'
            }
        ]

from django-webpack-loader.

darklow avatar darklow commented on August 19, 2024

@rawberg Thank you. This is very helpful.

from django-webpack-loader.

Related Issues (20)

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.