Skip to content

Commit

Permalink
Parameterize Sanity project and dataset vars
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-robert committed Apr 24, 2024
1 parent 9c50c3c commit d1c2963
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const viteEjsPlugin = ({ data }: { data: ejs.Data }): Plugin => ({
});

export default defineConfig(({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
const unitTest: UserConfig["test"] = {
globals: true,
exclude: [...configDefaults.exclude, "**/e2e/**"],
Expand Down Expand Up @@ -68,7 +69,9 @@ export default defineConfig(({ mode }) => {
globPatterns: ["**/*.{js,css,html,ico,png,svg,gif,hex}"],
runtimeCaching: [
{
urlPattern: /^https:\/\/ajwvhvgo.apicdn.sanity.io\/.*/,
urlPattern: new RegExp(
`^https://${process.env.VITE_SANITY_PROJECT}.apicdn.sanity.io/.*`
),
handler: "NetworkFirst",
options: {
cacheName: "sanity-content-cache",
Expand All @@ -81,8 +84,9 @@ export default defineConfig(({ mode }) => {
},
},
{
urlPattern:
/^https:\/\/cdn.sanity.io\/images\/ajwvhvgo\/apps\/.*/,
urlPattern: new RegExp(
`^https://cdn.sanity.io/images/${process.env.VITE_SANITY_PROJECT}/${process.env.VITE_SANITY_DATASET}/.*`
),
handler: "NetworkFirst",
options: {
cacheName: "sanity-images-cache",
Expand Down

0 comments on commit d1c2963

Please sign in to comment.