From 3fa55f9abff628e77f086c2939beda303b581404 Mon Sep 17 00:00:00 2001 From: YHhaoareyou Date: Tue, 31 May 2022 01:21:44 +0900 Subject: [PATCH 1/6] fix style prelload link --- root/src/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/root/src/index.html b/root/src/index.html index 9eda09d6f..e20824ae3 100644 --- a/root/src/index.html +++ b/root/src/index.html @@ -51,10 +51,10 @@ } } - - - - + + + + <% } else { %> - - - - + + + + <% } %> + } + + + <% if (isLocal) { %> + <% } else { %> - <% if (isDev) { %> - - - - - - <% } else { %> - - - - - - <% } %> + + + + + + + + + + - - - - - <% } %> - <% } else { %> - - <% } %> - + diff --git a/root/src/wasedatime-root-config.ts b/root/src/wasedatime-root-config.ts index 47c37ca51..a11942f42 100644 --- a/root/src/wasedatime-root-config.ts +++ b/root/src/wasedatime-root-config.ts @@ -50,18 +50,7 @@ i18nConfig({ }, }); -// ===== GA id ===== -// production (wasedatime.com): UA-112185819-1 -// staging (dev.wasedatime.com): UA-112185819-3 -// development (localhost): UA-112185819-4 -if (import.meta.env.MODE === "development") { - ReactGA.initialize("UA-112185819-4", { debug: false, titleCase: false }); -} else { - ReactGA.initialize( - import.meta.env.MODE === "production" ? "UA-112185819-1" : "UA-112185819-3", - { debug: false, titleCase: false } - ); -} +ReactGA.initialize(import.meta.env.VITE_GA_ID, { debug: false, titleCase: false }); ReactDOM.render( React.createElement("span"), diff --git a/root/vite.config.ts b/root/vite.config.ts index e80cdfbfb..53514a292 100644 --- a/root/vite.config.ts +++ b/root/vite.config.ts @@ -6,7 +6,7 @@ import { VitePWA } from "vite-plugin-pwa"; const path = require("path"); export default defineConfig(({ mode }) => { - const env = loadEnv(mode, process.cwd(), ""); + const env = loadEnv(mode, process.cwd() + "/src"); return { root: "./src", publicDir: "assets", @@ -30,14 +30,12 @@ export default defineConfig(({ mode }) => { assetFileNames: "assets/[name].[ext]", }, external: - mode === "staging" - ? [ - `https://${env.MF_PREFIX}.${env.MF_SYLLABUS_DOMAIN}/assets/style.css`, - `https://${env.MF_PREFIX}.${env.MF_CAMPUS_DOMAIN}/assets/style.css`, - ] - : mode === "production" - ? ["/syllabus/assets/style.css", "/campus/assets/style.css"] - : [], + mode === "development" + ? [] + : [ + `${env.VITE_MF_SYLLABUS_BASE_PATH}assets/style.css`, + `${env.VITE_MF_CAMPUS_BASE_PATH}assets/style.css`, + ], }, }, resolve: { @@ -55,8 +53,6 @@ export default defineConfig(({ mode }) => { plugins: [ ViteEjsPlugin((config) => ({ isLocal: config.mode === "development", - isDev: config.mode === "staging", - standalone: false, env, })), reactRefresh(), @@ -66,7 +62,7 @@ export default defineConfig(({ mode }) => { srcDir: ".", filename: "sw.js", registerType: "autoUpdate", - useCredentials: mode === "staging", + useCredentials: env.VITE_IS_STAGING === "true", includeAssets: [ "favicon.svg", "favicon.ico", diff --git a/syllabus/package.json b/syllabus/package.json index 78f8c9eda..aa22c29cc 100644 --- a/syllabus/package.json +++ b/syllabus/package.json @@ -5,9 +5,9 @@ "postinstall": "semantic-ui-css-patch", "start": "vite --port 8080", "build": "vite build", - "build-dev": "vite build --mode staging", + "build-dev": "vite build", "preview": "vite preview --port 8080", - "preview-dev": "vite preview --mode staging --port 8080", + "preview-dev": "vite preview --port 8080", "tsc": "tsc", "local": "concurrently --kill-others \"pnpm start\" \"cd ../root && pnpm start\"", "fix": "pnpm run format && pnpm run lint:fix", diff --git a/syllabus/src/components/labs/Lab.tsx b/syllabus/src/components/labs/Lab.tsx index 76774e7c7..1661a1a25 100644 --- a/syllabus/src/components/labs/Lab.tsx +++ b/syllabus/src/components/labs/Lab.tsx @@ -132,11 +132,12 @@ const ReviewsModal = styled.div` `; const LabHeader = styled.div` + height: 15%; padding: 1em; `; const ReviewsWrapper = styled(SimpleBar)` - height: 100%; + height: 85%; padding: 1em; .simplebar-scrollbar::before { background-color: #999; diff --git a/syllabus/src/root.component.tsx b/syllabus/src/root.component.tsx index 2241497f0..5c8c88495 100644 --- a/syllabus/src/root.component.tsx +++ b/syllabus/src/root.component.tsx @@ -33,21 +33,7 @@ API.configure(config); configAuth(); -if (import.meta.env.PROD) { - ReactGA.initialize("UA-112185819-1", { debug: false, titleCase: false }); - Sentry.init({ - dsn: "https://6730c6ebd6784cee8330d59452a33d13@o498993.ingest.sentry.io/5577049", - environment: import.meta.env.MODE, - ignoreErrors: [ - "Network Error", - "NetworkError", - "Loading chunk", - "Timed out", - ], - }); -} else { - ReactGA.initialize("UA-112185819-4", { debug: false, titleCase: false }); -} +ReactGA.initialize(import.meta.env.VITE_GA_ID, { debug: false, titleCase: false }); const LoadingSpinnerContainer = () => { const { theme } = useContext(ThemeContext); diff --git a/syllabus/vite.config.ts b/syllabus/vite.config.ts index 913395322..7b05a98f8 100644 --- a/syllabus/vite.config.ts +++ b/syllabus/vite.config.ts @@ -4,18 +4,12 @@ import dynamicImport from "vite-plugin-dynamic-import"; const path = require("path"); export default defineConfig(({ mode }) => { - const env = loadEnv(mode, process.cwd(), ""); - const publicAssetsBaseUrl = - mode === "production" - ? "/syllabus/" - : mode === "staging" - ? `https://${env.MF_DOMAIN_WITH_PREFIX}/` - : "http://localhost:8080/"; + const env = loadEnv(mode, process.cwd() + "/src"); return { root: "./src", publicDir: "assets", - base: publicAssetsBaseUrl, + base: env.VITE_PUBLIC_BASE_PATH, rollupOptions: { input: "wasedatime-syllabus.ts", preserveEntrySignatures: true, From 625047bd09449b92cf17d844d8f0fe7be40061c7 Mon Sep 17 00:00:00 2001 From: YHhaoareyou Date: Tue, 31 May 2022 11:48:42 +0900 Subject: [PATCH 3/6] remove slash from the end of base path env var --- campus/vite.config.ts | 2 +- root/src/components/Feeds.tsx | 2 +- root/src/index.html | 14 +++++++------- root/vite.config.ts | 4 ++-- syllabus/vite.config.ts | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/campus/vite.config.ts b/campus/vite.config.ts index ea2bee560..d6eb3d298 100644 --- a/campus/vite.config.ts +++ b/campus/vite.config.ts @@ -9,7 +9,7 @@ export default defineConfig(({ mode }) => { return { root: "./src", publicDir: "assets", - base: env.VITE_PUBLIC_BASE_PATH, + base: env.VITE_PUBLIC_BASE_PATH + "/", rollupOptions: { input: "wasedatime-campus.ts", preserveEntrySignatures: true, diff --git a/root/src/components/Feeds.tsx b/root/src/components/Feeds.tsx index e2732d174..a0fa281b1 100644 --- a/root/src/components/Feeds.tsx +++ b/root/src/components/Feeds.tsx @@ -45,7 +45,7 @@ const Feeds = () => {
{!feedsLoaded && }