-
Notifications
You must be signed in to change notification settings - Fork 340
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
Conversation
@@ -0,0 +1,31 @@ | |||
const isProduction = process.env.DFX_NETWORK === "ic"; | |||
|
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
I don't own this example so I'll just close this PR |
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