Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

vue3 backend django

//in django-app
pip install django-vite

//in django-app settings.py
INSTALLED_APPS = [
    ...
    'django_vite',
    ...
]

//in vue_app package.json
"scripts: {
  ...
  "build": "vue-tsc --noEmit && npm run build:client && npm run build:server",
  "build:client": "vite build --ssrManifest --outDir dist/client",
  "build:server": "vite build --ssr src/entry-server.js --outDir dist/server",
  ...
}
  
//in vue_app vite.config.ts
export default defineConfig({
  ...
    build: {
    // generate manifest.json in outDir
    manifest: true,
      // overwrite default .html entry
    outDir: resolve('<path-to-your-static-file>'),
    assetsDir: '',
    manifest: true,
    emptyOutDir: true,
    target: 'es2015',
    rollupOptions: {
      input: {
        main: resolve('<path-to-your-static-file>'),
      },
      output: {
        chunkFileNames: undefined,
      },
    },
  }
})

//in vue-app main.ts
import 'vite/modulepreload-polyfill'; PLEASE READ THIS "this will lead to Uncaught ReferenceError: __VITE_IS_MODERN__ is not defined" error
SO DO NOT IMPORT!

//in django-app settings.py
# Where ViteJS assets are built.
DJANGO_VITE_ASSETS_PATH = BASE_DIR / "static" / "dist"

# If use HMR or not.
DJANGO_VITE_DEV_MODE = DEBUG

# Name of static files folder (after called python manage.py collectstatic)
STATIC_ROOT = BASE_DIR / "collectedstatic"

# Include DJANGO_VITE_ASSETS_PATH into STATICFILES_DIRS to be copied inside
# when run command python manage.py collectstatic
STATICFILES_DIRS = [DJANGO_VITE_ASSETS_PATH]


  
Comment

PREVIOUS NEXT
Code Example
Typescript :: react forwardref useImperativeHandle typescript 
Typescript :: tostring typescript 
Typescript :: how to run typescript 
Typescript :: ts useSelector types react 
Typescript :: stored procedure that selects in to a table 
Typescript :: mongodb array not equal to value 
Typescript :: how to get just the ports in kubernetes 
Typescript :: check if enum contains value typescript 
Typescript :: typescript for 
Typescript :: File C:UsersPraveenAppDataRoaming pm g.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. 
Typescript :: react query staletime 
Typescript :: how to enable and disable gameobjects c# 
Typescript :: peer of typescript@=2.8.0 
Typescript :: capacitor base64 to file 
Typescript :: Implement a function that accepts 3 integer values a, b, c. The function should return true if a triangle can be built with the sides of given length and false in any other case. 
Typescript :: number of digits in a number python 
Typescript :: when i console log a obj its printing object 
Typescript :: react-native.ps1 cannot be loaded because running scripts is disabled on this system 
Typescript :: stylesheet not loaded because of mime-type 
Typescript :: angular subscribe catch stat 
Typescript :: highlight styled components on vscode 
Typescript :: how to sort documents in firebase database date wise 
Typescript :: typescript import particular class from file 
Typescript :: mocha test typescript 
Typescript :: python requests no follow redirect 
Typescript :: clone a list typescript 
Typescript :: moment datepicker 
Typescript :: c# linq get list of objects based on another list 
Typescript :: create custom objects for user in firebase 
Typescript :: how long does it take to learn typescript 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =