Static files not found with webpack and django

社会主义新天地 提交于 2019-12-04 08:17:57

In your HTML page did you load and render the bundle? This should be in your entry point Django template.

{% load render_bundle from webpack_loader %}
{% render_bundle 'app' %}

You also need the publicPath to match your static files setting in Django. Set it in webpack.config.js:

output: {
    path: path.resolve('assets/bundles/'),
    publicPath: '/static/bundles/',
    filename: "[name]-[hash].js",
},

If you run into this problem when running (Django) tests, make sure you have the webpack bundle built:

./node_modules/.bin/webpack --watch --progress --config webpack.config.js --colors

Then delete all .pyc file to clear op stale tests.

find -name "*.pyc" -delete

After this the tests should no longer complain about webpack not being able to find the bundle in question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!