Skip to content

Commit

Permalink
🔧 .env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
miyasan31 committed Jun 19, 2022
1 parent 1df20cb commit 0d52b40
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ module.exports = {
},

overrides: [
{
files: ["*.d.ts"],
rules: {
"no-unused-vars": "off",
},
},
{
files: ["tests/**.{ts,tsx}"],
rules: {
Expand Down
2 changes: 2 additions & 0 deletions env/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# npm run dev
VITE_ENV_API_URL="http://localhost:4000"
1 change: 1 addition & 0 deletions env/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# npm run build && npm run preview
1 change: 1 addition & 0 deletions env/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://vitejs.dev/guide/env-and-mode.html#env-variables-and-modes
10 changes: 10 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference types="vite/client" />
/// <reference types="vite-plugin-pwa/client" />

interface ImportMetaEnv {
readonly VITE_ENV_API_URL: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
2 changes: 0 additions & 2 deletions vite-env.d.ts

This file was deleted.

3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="vitest" />

import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import type { VitePWAOptions } from "vite-plugin-pwa";
Expand Down Expand Up @@ -35,6 +37,7 @@ const pwaOptions: Partial<VitePWAOptions> = {
export default defineConfig({
plugins: [react(), tsconfigPaths(), VitePWA(pwaOptions)],
assetsInclude: ["robots.txt"],
envDir: "./environments",
test: {
globals: true,
environment: "jsdom",
Expand Down

0 comments on commit 0d52b40

Please sign in to comment.