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

feat: restructuring exchange_rate with vite and env variables #462

Closed
wants to merge 2 commits into from

Conversation

krpeacock
Copy link
Contributor

Overview
Currently the rollup config is not working. Rather than maintaining the rollup config, this change brings the project in line with SDK's current feature set

@krpeacock krpeacock requested a review from a team as a code owner February 22, 2023 21:10
@@ -0,0 +1,31 @@
const isProduction = process.env.DFX_NETWORK === "ic";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much simpler config than rollup.config.js 👍

},
"dependencies": {
"@dfinity/agent": "^0.15.1",
"@dfinity/principal": "^0.15.1",
"@dfinity/candid": "^0.15.1",
"chart.js": "3.8.0",
"sirv-cli": "^1.0.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't sirv-cli anymore no?

@@ -5,7 +5,7 @@ import { idlFactory } from "./exchange_rate.did.js";
export { idlFactory } from "./exchange_rate.did.js";

// CANISTER_ID is replaced by webpack based on node environment
export const canisterId = process.env.EXCHANGE_RATE_CANISTER_ID;
export const canisterId = process.env.CANISTER_ID_exchange_rate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we migrate to vite, I think we should also use environment variable as when you use vite - i.e. .env and not process.env... but import.meta.env...

https://vitejs.dev/guide/env-and-mode.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not deprecating webpack at this point

import { exchange_rate } from "../../../declarations/exchange_rate/index.js";
import {createActor} from '../../declarations/exchange_rate';
const canisterId = process.env.CANISTER_ID_exchange_rate;
const exchange_rate = createActor(canisterId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nth: prefixing or suffixing the variable with actor could be easier to read for the community that tries this sample?

emptyOutDir: true,
},
define: {
global: "window",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you try a prod build? nothing else to polyfill?

npm run build && npx serve dist

import EnvironmentPlugin from "vite-plugin-environment";

export default defineConfig({
mode: isProduction ? "production" : "development",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is setting the mode required? doesn't vite does it automatically?

"start": "sirv src/frontend/public --no-clear --port 5555"
"build": "vite build",
"dev": "npm start",
"start": "vite --port 5555"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vite and sveltekit uses port 5173, would be handy to inherits this port

@krpeacock
Copy link
Contributor Author

I don't own this example so I'll just close this PR

@krpeacock krpeacock closed this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants