Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Conditional https in local mode #285

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/frontend/certs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# this folder is for ssl certs for dev only
!.gitignore
*
4 changes: 2 additions & 2 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"prepare": "export VITE_COMMIT=$(git rev-parse --short HEAD)",
"dev": "pwa-assets-generator && VITE_COMMIT=$(git rev-parse --short HEAD) vite",
"dev:ssl": "yarn dev --host --port 443",
"dev:ssl": "USE_SSL=true yarn dev --host --port 443",
"build": "pwa-assets-generator && VITE_COMMIT=$(git rev-parse --short HEAD) vite build",
"build:apk": "ionic capacitor build android",
"platform:add": "ionic capacitor add",
Expand Down Expand Up @@ -95,4 +95,4 @@
"vite-plugin-pwa": "0.19.2",
"vite-plugin-svgr": "3.2.0"
}
}
}
89 changes: 49 additions & 40 deletions packages/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@
import * as path from "path";
import basicSsl from "@vitejs/plugin-basic-ssl";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { defineConfig, loadEnv } from "vite";
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
import { optimizeCssModules } from "vite-plugin-optimize-css-modules";
import { VitePWA } from "vite-plugin-pwa";
import svgr from "vite-plugin-svgr";
import tsconfigPaths from "vite-tsconfig-paths";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
basicSsl({
name: "Alphaday",
domains: ["app.localday.com"],
certDir: process.env.CERT_DIR || path.resolve(__dirname, "certs"),
}),
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const plugins = [
tsconfigPaths(),
VitePWA({
registerType: "autoUpdate",
Expand Down Expand Up @@ -64,40 +60,53 @@ export default defineConfig({
svgr(),
ViteImageOptimizer(), // optimize images, svgs and gifs
optimizeCssModules(), // optimize css modules
],
css: {
modules: {
localsConvention: "camelCase",
];
if (env.USE_SSL === "true") {
plugins.push(
basicSsl({
name: "Alphaday",
domains: ["app.localday.com"],
certDir:
process.env.CERT_DIR || path.resolve(__dirname, "certs"),
})
);
}
return {
plugins,
css: {
modules: {
localsConvention: "camelCase",
},
},
server: {
port: 3001,
},
},
server: {
port: 3001,
},
test: {
globals: true,
environment: "happy-dom",
},
build: {
commonjsOptions: {
transformMixedEsModules: true,
test: {
globals: true,
environment: "happy-dom",
},
build: {
commonjsOptions: {
transformMixedEsModules: true,
},
},
resolve: {
alias: {
// hack to prevent uniswap widgets error on vite (see https://github.com/Uniswap/sdk-core/issues/20)
jsbi: path.resolve(
__dirname,
"../..",
"node_modules",
"jsbi",
"dist",
"jsbi-cjs.js"
),
},
},
},
resolve: {
alias: {
// hack to prevent uniswap widgets error on vite (see https://github.com/Uniswap/sdk-core/issues/20)
jsbi: path.resolve(
__dirname,
"../..",
"node_modules",
"jsbi",
"dist",
"jsbi-cjs.js"
define: {
"import.meta.env.VITE_VERSION": JSON.stringify(
process.env.npm_package_version
),
},
},
define: {
"import.meta.env.VITE_VERSION": JSON.stringify(
process.env.npm_package_version
),
},
};
});
Loading