From a6ce396fa21a84ec549075b9d0e2c3fd24778a0d Mon Sep 17 00:00:00 2001 From: Kasper Seweryn Date: Mon, 21 Feb 2022 23:16:48 +0100 Subject: [PATCH] Fix django-channels import `django-channels` module has only dist files which are built with parcel. This leads to `assignment to undeclared variable parcelRequire` error. A simple workaround is to add `var parcelRequire;` to the beginning of the module. --- front/vite.config.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/front/vite.config.js b/front/vite.config.js index c44ed99a4..848e3d662 100644 --- a/front/vite.config.js +++ b/front/vite.config.js @@ -3,11 +3,21 @@ import { defineConfig } from 'vite' import { createVuePlugin as vue } from "vite-plugin-vue2"; -const path = require("path"); +import path from 'path' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [vue()], + plugins: [ + vue(), + { + name: 'fix-django-channels', + transform (src, id) { + if (id.includes('django-channels')) { + return `var parcelRequire;${src}` + } + } + } + ], resolve: { alias: { "@": path.resolve(__dirname, "./src"),