use vite env

This commit is contained in:
castdrian 2023-07-22 21:41:15 +02:00
parent d371321116
commit dce6dff9a1
No known key found for this signature in database
4 changed files with 94 additions and 98 deletions

View File

@ -1,3 +1,4 @@
# make sure the cors proxy url does NOT have a slash at the end # make sure the cors proxy url does NOT have a slash at the end
VITE_CORS_PROXY_URL=... VITE_CORS_PROXY_URL=...
VITE_TMDB_READ_API_KEY=... VITE_TMDB_READ_API_KEY=...
VITE_APP_DOMAIN="http://localhost:5173"

View File

@ -13,7 +13,6 @@
"core-js": "^3.29.1", "core-js": "^3.29.1",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"dompurify": "^3.0.1", "dompurify": "^3.0.1",
"dotenv": "^16.3.1",
"fscreen": "^1.2.0", "fscreen": "^1.2.0",
"fuse.js": "^6.4.6", "fuse.js": "^6.4.6",
"hls.js": "^1.0.7", "hls.js": "^1.0.7",

View File

@ -5,98 +5,99 @@ import { VitePWA } from "vite-plugin-pwa";
import checker from "vite-plugin-checker"; import checker from "vite-plugin-checker";
import path from "path"; import path from "path";
import { handlebars } from "./plugins/handlebars"; import { handlebars } from "./plugins/handlebars";
import dotenv from 'dotenv'; import { loadEnv } from "vite"
dotenv.config();
export default defineConfig({ export default defineConfig(({ mode }) => {
plugins:[ return {
handlebars({ plugins:[
vars: { handlebars({
appdomain: process.env.APP_DOMAIN, vars: {
}, appdomain: loadEnv(mode, process.cwd()).VITE_APP_DOMAIN,
}), },
react({ }),
babel: { react({
presets: [ babel: {
"@babel/preset-typescript", presets: [
[ "@babel/preset-typescript",
"@babel/preset-env", [
{ "@babel/preset-env",
modules: false, {
useBuiltIns: "entry", modules: false,
corejs: { useBuiltIns: "entry",
version: "3.29", corejs: {
}, version: "3.29",
}, },
], },
], ],
}, ],
}), },
VitePWA({ }),
registerType: "autoUpdate", VitePWA({
workbox: { registerType: "autoUpdate",
globIgnores: ["**ping.txt**"], workbox: {
}, globIgnores: ["**ping.txt**"],
includeAssets: [ },
"favicon.ico", includeAssets: [
"apple-touch-icon.png", "favicon.ico",
"safari-pinned-tab.svg", "apple-touch-icon.png",
], "safari-pinned-tab.svg",
manifest: { ],
name: "movie-web", manifest: {
short_name: "movie-web", name: "movie-web",
description: "The place for your favourite movies & shows", short_name: "movie-web",
theme_color: "#120f1d", description: "The place for your favourite movies & shows",
background_color: "#120f1d", theme_color: "#120f1d",
display: "standalone", background_color: "#120f1d",
start_url: "/", display: "standalone",
icons: [ start_url: "/",
{ icons: [
src: "android-chrome-192x192.png", {
sizes: "192x192", src: "android-chrome-192x192.png",
type: "image/png", sizes: "192x192",
purpose: "any", type: "image/png",
}, purpose: "any",
{ },
src: "android-chrome-512x512.png", {
sizes: "512x512", src: "android-chrome-512x512.png",
type: "image/png", sizes: "512x512",
purpose: "any", type: "image/png",
}, purpose: "any",
{ },
src: "android-chrome-192x192.png", {
sizes: "192x192", src: "android-chrome-192x192.png",
type: "image/png", sizes: "192x192",
purpose: "maskable", type: "image/png",
}, purpose: "maskable",
{ },
src: "android-chrome-512x512.png", {
sizes: "512x512", src: "android-chrome-512x512.png",
type: "image/png", sizes: "512x512",
purpose: "maskable", type: "image/png",
}, purpose: "maskable",
], },
}, ],
}), },
loadVersion(), }),
checker({ loadVersion(),
typescript: true, // check typescript build errors in dev server checker({
eslint: { typescript: true, // check typescript build errors in dev server
// check lint errors in dev server eslint: {
lintCommand: "eslint --ext .tsx,.ts src", // check lint errors in dev server
dev: { lintCommand: "eslint --ext .tsx,.ts src",
logLevel: ["error"], dev: {
}, logLevel: ["error"],
}, },
}), },
], }),
resolve: { ],
alias: { resolve: {
"@": path.resolve(__dirname, "./src"), alias: {
}, "@": path.resolve(__dirname, "./src"),
}, },
},
test: { test: {
environment: "jsdom", environment: "jsdom",
}, },
};
}); });

View File

@ -2448,11 +2448,6 @@ dompurify@^3.0.1:
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.0.2.tgz#bc4c7c011c825e7704341a285461d8d407d9429a" resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.0.2.tgz#bc4c7c011c825e7704341a285461d8d407d9429a"
integrity sha512-B8c6JdiEpxAKnd8Dm++QQxJL4lfuc757scZtcapj6qjTjrQzyq5iAyznLKVvK+77eYNiFblHBlt7MM0fOeqoKw== integrity sha512-B8c6JdiEpxAKnd8Dm++QQxJL4lfuc757scZtcapj6qjTjrQzyq5iAyznLKVvK+77eYNiFblHBlt7MM0fOeqoKw==
dotenv@^16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==
eastasianwidth@^0.2.0: eastasianwidth@^0.2.0:
version "0.2.0" version "0.2.0"
resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb"