@playpilot/tpi 8.40.0-beta.5 → 8.40.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/.playpilot/repo.yaml +14 -0
  2. package/dist/editorial.mount.js +10 -10
  3. package/dist/link-injections.js +2 -2
  4. package/dist/mount.css +1 -1
  5. package/dist/mount.js +8 -8
  6. package/package.json +3 -3
  7. package/src/lib/api/ads.ts +3 -1
  8. package/src/lib/api/config.ts +4 -0
  9. package/src/lib/api/region.ts +2 -1
  10. package/src/lib/disclaimer.ts +4 -3
  11. package/src/lib/explore.ts +2 -5
  12. package/src/lib/injection.ts +535 -537
  13. package/src/lib/retargeting.ts +2 -1
  14. package/src/lib/routes.ts +2 -1
  15. package/src/lib/types/config.d.ts +0 -1
  16. package/src/lib/user.ts +2 -1
  17. package/src/routes/+page.svelte +3 -3
  18. package/src/routes/components/Debugger.svelte +3 -10
  19. package/src/routes/components/Explore/ExploreCallToAction.svelte +2 -1
  20. package/src/routes/components/Explore/ExploreLayout.svelte +10 -18
  21. package/src/routes/components/Explore/ExploreRouter.svelte +9 -15
  22. package/src/routes/components/Explore/Routes/ExploreHome.svelte +1 -1
  23. package/src/routes/components/Modals/TitleModal.svelte +2 -1
  24. package/src/routes/components/Playlinks/Playlink.svelte +2 -1
  25. package/src/routes/components/Playlinks/Playlinks.svelte +2 -1
  26. package/src/routes/components/PostersScrollReveal.svelte +2 -1
  27. package/src/routes/components/Rails/ParticipantsRail.svelte +2 -1
  28. package/src/routes/components/Rails/TitlesRail.svelte +1 -6
  29. package/src/routes/components/Widgets/InjectionsWidgetRail.svelte +2 -1
  30. package/src/routes/explore/+page.svelte +2 -8
  31. package/src/tests/lib/api/ads.test.js +8 -0
  32. package/src/tests/routes/+page.test.js +8 -3
  33. package/svelte.config.js +32 -23
  34. package/vite.config.js +43 -43
@@ -1,9 +1,10 @@
1
1
  import { RETARGETING_USER_ID_KEY } from '@playpilot/retargeting-tracking'
2
2
  import { hasConsentedTo } from './consent'
3
3
  import { getUserId } from './user'
4
+ import { getConfigValue } from './api/config'
4
5
 
5
6
  export function isRetargetingAllowed(): boolean {
6
- if (!window.PlayPilotLinkInjections.config?.allow_retargeting_pixels) return false
7
+ if (!getConfigValue('allow_retargeting_pixels')) return false
7
8
 
8
9
  if (!hasConsentedTo('pixels')) return false
9
10
 
package/src/lib/routes.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { getConfigValue } from './api/config'
1
2
  import { playPilotBaseUrl } from './constants'
2
3
  import type { ParticipantData } from './types/participant'
3
4
  import type { TitleData } from './types/title'
@@ -11,5 +12,5 @@ export function participantUrl(participant: ParticipantData): string {
11
12
  }
12
13
 
13
14
  export function exploreModalUrl(sid: string): string {
14
- return window.PlayPilotLinkInjections?.config?.explore_navigation_path + `?route=modal&sid=${sid}`
15
+ return getConfigValue('explore_navigation_path') + `?route=modal&sid=${sid}`
15
16
  }
@@ -139,5 +139,4 @@ export type ConfigResponse = {
139
139
  explore_navigation_insert_position?: InsertPosition
140
140
  explore_insert_cta_in_tpi?: boolean
141
141
  explore_custom_style?: string
142
- explore_use_router?: boolean
143
142
  }
package/src/lib/user.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { getConfigValue } from './api/config'
1
2
  import { hasConsentedTo } from './consent'
2
3
  import { generateRandomHash } from './hash'
3
4
 
@@ -33,5 +34,5 @@ export function getSessionId(): string | null {
33
34
  }
34
35
 
35
36
  export function isUserTrackingAllowed(): boolean {
36
- return !!window.PlayPilotLinkInjections?.config?.allow_user_id_tracking && hasConsentedTo('tracking')
37
+ return !!getConfigValue('allow_user_id_tracking') && hasConsentedTo('tracking')
37
38
  }
@@ -7,7 +7,7 @@
7
7
  import { isCrawler } from '$lib/crawler'
8
8
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
9
9
  import { fetchAds } from '$lib/api/ads'
10
- import { fetchConfig } from '$lib/api/config'
10
+ import { fetchConfig, getConfigValue } from '$lib/api/config'
11
11
  import { insertExplore, insertExploreIntoNavigation } from '$lib/explore'
12
12
  import { authorize, getAuthToken, isEditorialModeEnabled, removeAuthCookie, setEditorialParamInUrl } from '$lib/api/auth'
13
13
  import { getPageTextAndElements } from '$lib/injectionElements'
@@ -55,7 +55,7 @@
55
55
  fireQueuedTrackingEvents()
56
56
  track(TrackingEvent.ArticlePageView)
57
57
 
58
- const explorePath = window.PlayPilotLinkInjections.config?.explore_navigation_path
58
+ const explorePath = getConfigValue('explore_navigation_path')
59
59
 
60
60
  if ((!aiInjections.length && !manualInjections.length) && !(explorePath && document.location.href.includes(explorePath))) return
61
61
 
@@ -102,7 +102,7 @@
102
102
  loading = false
103
103
 
104
104
  if (!response) return
105
- if (window.PlayPilotLinkInjections.config?.disable_public_injections && !(isEditorialMode && authorized)) return
105
+ if (getConfigValue('disable_public_injections') && !(isEditorialMode && authorized)) return
106
106
 
107
107
  setTrackingSids({ organizationSid: response.organization_sid, domainSid: response.domain_sid })
108
108
 
@@ -1,8 +1,9 @@
1
1
  <script lang="ts">
2
+ import { getConfigValue } from '$lib/api/config'
2
3
  import { fetchLinkInjections } from '$lib/api/externalPages'
3
4
  import { Language } from '$lib/enums/Language'
4
5
  import { SplitTest } from '$lib/enums/SplitTest'
5
- import { destroyExplore, insertExplore, useExploreRouter } from '$lib/explore'
6
+ import { destroyExplore, insertExplore } from '$lib/explore'
6
7
  import { getPageTextAndElements } from '$lib/injectionElements'
7
8
  import { getLanguage } from '$lib/language'
8
9
  import { getFullUrlPath } from '$lib/url'
@@ -131,7 +132,7 @@
131
132
 
132
133
  <hr />
133
134
 
134
- {#if !!(window.PlayPilotLinkInjections.config?.exclude_urls_pattern && getFullUrlPath().match(window.PlayPilotLinkInjections?.config?.exclude_urls_pattern))}
135
+ {#if !!(getConfigValue('exclude_urls_pattern') && getFullUrlPath().match(getConfigValue('exclude_urls_pattern')!))}
135
136
  <span class="error">The current URL is excluded via the config</span>
136
137
  <hr />
137
138
  {/if}
@@ -216,14 +217,6 @@
216
217
  <button onclick={replaceWithBetaScript}>Use beta script</button>
217
218
  {/if}
218
219
 
219
- {#if !useExploreRouter()}
220
- <button onclick={(() => {
221
- destroyExplore()
222
- window.PlayPilotLinkInjections.config!.explore_use_router = !useExploreRouter()
223
- insertExplore()
224
- })}>Toggle new explore</button>
225
- {/if}
226
-
227
220
  <hr />
228
221
 
229
222
  <div>
@@ -1,10 +1,11 @@
1
1
  <script lang="ts">
2
+ import { getConfigValue } from '$lib/api/config'
2
3
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
3
4
  import { track } from '$lib/tracking'
4
5
  import IconArrow from '../Icons/IconArrow.svelte'
5
6
 
6
7
  const src = 'https://cdn.jsdelivr.net/npm/@playpilot/tpi@latest/src/lib/images/titles-list.webp'
7
- const href = window.PlayPilotLinkInjections?.config?.explore_navigation_path
8
+ const href = getConfigValue('explore_navigation_path')
8
9
  </script>
9
10
 
10
11
  <a class="call-to-action" {href} onclick={() => track(TrackingEvent.CardToExploreCta)}>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { ExploreFilter } from '$lib/types/filter'
3
3
  import { heading } from '$lib/actions/heading'
4
- import { exploreParentSelector, useExploreRouter } from '$lib/explore'
4
+ import { exploreParentSelector } from '$lib/explore'
5
5
  import { t } from '$lib/localization'
6
6
  import { track } from '$lib/tracking'
7
7
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
@@ -57,28 +57,20 @@
57
57
  <!-- eslint-disable-next-line svelte/no-at-html-tags -->
58
58
  {@html t('Streaming Guide Disclaimer')}
59
59
  </p>
60
-
61
- {#if !useExploreRouter()}
62
- <p class="description">
63
- {t('Streaming Guide Description')}
64
- </p>
65
- {/if}
66
60
  </div>
67
61
  </div>
68
62
 
69
63
  <Search oninput={(query) => searchQuery = query} />
70
64
 
71
- {#if useExploreRouter()}
72
- <div class="filter">
73
- <Filter
74
- {filter}
75
- {searchQuery}
76
- limit={clientWidth < 500}
77
- showSorting={!searchQuery}
78
- onchange={() => navigate('results')}
79
- onempty={() => navigate('home')} />
80
- </div>
81
- {/if}
65
+ <div class="filter">
66
+ <Filter
67
+ {filter}
68
+ {searchQuery}
69
+ limit={clientWidth < 500}
70
+ showSorting={!searchQuery}
71
+ onchange={() => navigate('results')}
72
+ onempty={() => navigate('home')} />
73
+ </div>
82
74
 
83
75
  {#await isUserRegionSupported() then isSupported}
84
76
  {#if !isSupported}
@@ -1,7 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { ExploreRoute } from '$lib/types/explore'
3
3
  import type { ExploreFilter } from '$lib/types/filter'
4
- import { useExploreRouter } from '$lib/explore'
5
4
  import { track } from '$lib/tracking'
6
5
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
7
6
  import ExploreHome from './Routes/ExploreHome.svelte'
@@ -11,29 +10,24 @@
11
10
  import ExploreModal from './Routes/ExploreModal.svelte'
12
11
 
13
12
  const routes: ExploreRoute[] = [
13
+ {
14
+ key: 'home',
15
+ component: ExploreHome,
16
+ },
14
17
  {
15
18
  key: 'results',
16
19
  component: ExploreResults,
17
20
  },
18
- ]
19
-
20
- if (useExploreRouter()) {
21
- routes.unshift({
22
- key: 'home',
23
- component: ExploreHome,
24
- })
25
-
26
- routes.push({
21
+ {
27
22
  key: 'title',
28
23
  component: ExploreTitle,
29
- })
30
-
31
- routes.push({
24
+ },
25
+ {
32
26
  key: 'modal',
33
27
  component: ExploreHome,
34
28
  appendComponent: ExploreModal,
35
- })
36
- }
29
+ }
30
+ ]
37
31
 
38
32
  const initialRouteKey = getCurrentRouteParam() || routes[0].key
39
33
 
@@ -32,7 +32,7 @@
32
32
  }
33
33
  </script>
34
34
 
35
- <svelte:window {onscroll} bind:innerWidth={windowWidth} />
35
+ <svelte:window bind:innerWidth={windowWidth} />
36
36
 
37
37
  <div data-testid="explore-home"></div>
38
38
 
@@ -6,6 +6,7 @@
6
6
  import { exploreParentSelector } from '$lib/explore'
7
7
  import { onMount, setContext } from 'svelte'
8
8
  import { isRetargetingAllowed } from '$lib/retargeting'
9
+ import { getConfigValue } from '$lib/api/config'
9
10
  import { trackViaPixel } from '@playpilot/retargeting-tracking'
10
11
  import Modal from './Modal.svelte'
11
12
  import Title from '../Title.svelte'
@@ -24,7 +25,7 @@
24
25
 
25
26
  const topScrollAd = getFirstAdOfType('top_scroll')
26
27
  const displayAd = getFirstAdOfType('card')
27
- const insertExploreCta = window.PlayPilotLinkInjections?.config?.explore_insert_cta_in_tpi
28
+ const insertExploreCta = getConfigValue('explore_insert_cta_in_tpi')
28
29
  const useBubble = !!topScrollAd || (insertExploreCta && !document.querySelector(exploreParentSelector))
29
30
 
30
31
  let hasTrackedScrolling = false
@@ -8,6 +8,7 @@
8
8
  import { trackClickViaPixel, trackViewViaPixel } from '@playpilot/retargeting-tracking'
9
9
  import { MetaEvent, MetaSource } from '$lib/enums/TrackingEvent'
10
10
  import { isRetargetingAllowed } from '$lib/retargeting'
11
+ import { getConfigValue } from '$lib/api/config'
11
12
 
12
13
  interface Props {
13
14
  playlink: PlaylinkData
@@ -36,7 +37,7 @@
36
37
  <!-- svelte-ignore a11y_no_static_element_interactions -->
37
38
  <svelte:element
38
39
  {onclick}
39
- this={!window.PlayPilotLinkInjections?.config?.require_affiliate_consent || hasConsentedTo('affiliate') ? 'a' : 'span'}
40
+ this={!getConfigValue('require_affiliate_consent') || hasConsentedTo('affiliate') ? 'a' : 'span'}
40
41
  {@attach usePixel ? trackViewViaPixel(MetaEvent.ProviderInterest, { provider: playlink.slug, source: MetaSource.Card }) : null}
41
42
  {@attach usePixel ? trackClickViaPixel(MetaEvent.ProviderClick, { provider: playlink.slug }) : null}
42
43
  href={url}
@@ -11,6 +11,7 @@
11
11
  import Playlink from './Playlink.svelte'
12
12
  import Button from '../Button.svelte'
13
13
  import PlaylinksDisclaimer from './PlaylinksDisclaimer.svelte'
14
+ import { getConfigValue } from '$lib/api/config'
14
15
 
15
16
  type Category = PlaylinkCategory | '' | 'Other'
16
17
  type CategorizedPlaylinks = Partial<Record<Category, PlaylinkData[]>>
@@ -27,7 +28,7 @@
27
28
  const isModal = getContext('scope') === 'modal'
28
29
  const type = getContext('type')
29
30
  const displayAd = getFirstAdOfType('card')
30
- const categorize = !!window.PlayPilotLinkInjections?.config?.categorize_playlinks
31
+ const categorize = !!getConfigValue('categorize_playlinks')
31
32
 
32
33
  let outerWidth = $state(0)
33
34
  let limited = $state(!categorize)
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { getConfigValue } from '$lib/api/config'
2
3
  import { mobileBreakpoint } from '$lib/constants'
3
4
  import { onDestroy } from 'svelte'
4
5
  import { SvelteSet } from 'svelte/reactivity'
@@ -17,7 +18,7 @@
17
18
  onDestroy(destroyAllPosters)
18
19
 
19
20
  function onscroll(): void {
20
- if (window.PlayPilotLinkInjections?.config?.disable_scroll_reveal_posters) return
21
+ if (getConfigValue('disable_scroll_reveal_posters')) return
21
22
  if (!isMobile) return
22
23
 
23
24
  setScrollTimeout()
@@ -11,6 +11,7 @@
11
11
  import ParticipantImage from '../Participants/ParticipantImage.svelte'
12
12
  import Rail from './Rail.svelte'
13
13
  import { exploreModalUrl } from '$lib/routes'
14
+ import { getConfigValue } from '$lib/api/config'
14
15
 
15
16
  interface Props {
16
17
  title: TitleData
@@ -45,7 +46,7 @@
45
46
  async function onclick(event: MouseEvent, participant: ParticipantData): Promise<void> {
46
47
  track(TrackingEvent.ParticipantClick, null, { title_source: title.original_title || title.title, participant: participant.name })
47
48
 
48
- if (!window.PlayPilotLinkInjections?.config?.open_tpi_links_in_explore || window.location.href.includes(window.PlayPilotLinkInjections.config.explore_navigation_path || '')) {
49
+ if (!getConfigValue('open_tpi_links_in_explore') || window.location.href.includes(getConfigValue('explore_navigation_path') || '')) {
49
50
  const fetchedParticipant = await fetchParticipantBySid(participant.sid)
50
51
 
51
52
  openModal({ event, type: 'participant', data: fetchedParticipant })
@@ -8,7 +8,6 @@
8
8
  import { exploreModalUrl } from '$lib/routes'
9
9
  import { generateRandomHash } from '$lib/hash'
10
10
  import { getFirstTitleWithAvailableTrailer } from '$lib/trailer'
11
- import { useExploreRouter } from '$lib/explore'
12
11
  import { getContext, onMount } from 'svelte'
13
12
  import type TinySlider from 'svelte-tiny-slider'
14
13
 
@@ -92,11 +91,7 @@
92
91
  return
93
92
  }
94
93
 
95
- if (useExploreRouter()) {
96
- openModal({ event, type: 'titles-rail', data: titles as TitleData[], returnToTitle, props: { initialIndex: index } })
97
- } else {
98
- openModal({ event, data: title, returnToTitle })
99
- }
94
+ openModal({ event, type: 'titles-rail', data: titles as TitleData[], returnToTitle, props: { initialIndex: index } })
100
95
  }
101
96
 
102
97
  async function expandFirstAvailableTrailer(): Promise<void> {
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { getConfigValue } from '$lib/api/config'
2
3
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
3
4
  import { t } from '$lib/localization'
4
5
  import { track } from '$lib/tracking'
@@ -38,7 +39,7 @@
38
39
  <TitlesRail
39
40
  {titles}
40
41
  {heading}
41
- navigateToExplore={!!window.PlayPilotLinkInjections?.config?.open_tpi_links_in_explore}
42
+ navigateToExplore={!!getConfigValue('open_tpi_links_in_explore')}
42
43
  onclick={(title) => track(TrackingEvent.WidgetArticleRailTitleClick, title)} />
43
44
  </div>
44
45
  {/if}
@@ -6,9 +6,8 @@
6
6
  */
7
7
 
8
8
  import { browser } from '$app/environment'
9
- import { destroyExplore, insertExplore, insertExploreIntoNavigation, useExploreRouter } from '$lib/explore'
9
+ import { insertExplore, insertExploreIntoNavigation } from '$lib/explore'
10
10
  import Debugger from '../components/Debugger.svelte'
11
-
12
11
  if (browser) {
13
12
  // @ts-ignore
14
13
  window.PlayPilotLinkInjections = {
@@ -18,7 +17,6 @@
18
17
  explore_navigation_label: 'Streaming guide (inserted)',
19
18
  explore_navigation_path: '/explore',
20
19
  explore_custom_style: 'main { border: 2px solid white }',
21
- explore_use_router: true,
22
20
  open_tpi_links_in_explore: true,
23
21
  },
24
22
  require_consent: false,
@@ -34,11 +32,7 @@
34
32
  <title>PlayPilot Link Injections - Explore</title>
35
33
  </svelte:head>
36
34
 
37
- <button onclick={(() => {
38
- destroyExplore()
39
- window.PlayPilotLinkInjections.config!.explore_use_router = !useExploreRouter()
40
- insertExplore()
41
- })}>Toggle new explore</button>
35
+
42
36
 
43
37
  <main>
44
38
  <!--
@@ -72,6 +72,14 @@ describe('$lib/api/ads', () => {
72
72
  await expect(async () => await fetchAds()).rejects.toThrowError()
73
73
  expect(track).toHaveBeenCalledWith(TrackingEvent.AdsFetchFailed, null, { status: 505 })
74
74
  })
75
+
76
+ it('Should include set region', async () => {
77
+ window.PlayPilotLinkInjections.region = 'uk'
78
+
79
+ await fetchAds()
80
+
81
+ expect(api).toHaveBeenCalledWith(expect.stringContaining('&region=uk'))
82
+ })
75
83
  })
76
84
 
77
85
  describe('getFirstAdOfType', () => {
@@ -19,9 +19,14 @@ vi.mock('$lib/api/externalPages', () => ({
19
19
  pollLinkInjections: vi.fn(() => {}),
20
20
  }))
21
21
 
22
- vi.mock('$lib/api/config', () => ({
23
- fetchConfig: vi.fn(),
24
- }))
22
+ // @ts-ignore
23
+ vi.mock(import('$lib/api/config'), async (importOriginal) => {
24
+ const actual = await importOriginal()
25
+ return {
26
+ ...actual,
27
+ fetchConfig: vi.fn(() => {}),
28
+ }
29
+ })
25
30
 
26
31
  // @ts-ignore
27
32
  vi.mock(import('$lib/api/session'), async (importOriginal) => {
package/svelte.config.js CHANGED
@@ -1,23 +1,32 @@
1
- import adapter from '@sveltejs/adapter-auto'
2
- import { sveltePreprocess } from 'svelte-preprocess'
3
-
4
- /** @type {import('@sveltejs/kit').Config} */
5
- const config = {
6
- preprocess: sveltePreprocess({
7
- scss: {
8
- includePaths: ['src'],
9
- prependData: `
10
- @use "src/lib/scss/_functions.scss" as *;
11
- @use "src/lib/scss/_mixins.scss" as *;
12
- `,
13
- },
14
- }),
15
- kit: {
16
- // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
17
- // If your environment is not supported, or you settled on a specific environment, switch out the adapter.
18
- // See https://svelte.dev/docs/kit/adapters for more information about adapters.
19
- adapter: adapter(),
20
- },
21
- }
22
-
23
- export default config
1
+ import adapter from '@sveltejs/adapter-auto'
2
+ import { sveltePreprocess } from 'svelte-preprocess'
3
+
4
+ /** @type {import('@sveltejs/kit').Config} */
5
+ const config = {
6
+ preprocess: sveltePreprocess({
7
+ scss: {
8
+ includePaths: ['src'],
9
+ prependData: `
10
+ @use "src/lib/scss/_functions.scss" as *;
11
+ @use "src/lib/scss/_mixins.scss" as *;
12
+ `,
13
+ },
14
+ }),
15
+ kit: {
16
+ // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
17
+ // If your environment is not supported, or you settled on a specific environment, switch out the adapter.
18
+ // See https://svelte.dev/docs/kit/adapters for more information about adapters.
19
+ adapter: adapter(),
20
+ },
21
+ compilerOptions: {
22
+ warningFilter: (warning) => {
23
+ const ignore = [
24
+ 'state_referenced_locally',
25
+ ]
26
+
27
+ return !ignore.includes(warning.code)
28
+ },
29
+ },
30
+ }
31
+
32
+ export default config
package/vite.config.js CHANGED
@@ -1,43 +1,43 @@
1
- import path from 'path'
2
- import * as dotenv from 'dotenv'
3
- import { defineConfig } from 'vitest/config'
4
- import { sveltekit } from '@sveltejs/kit/vite'
5
- import packageJson from './package.json'
6
-
7
- dotenv.config({ path: '.env' })
8
-
9
- export default defineConfig(() => ({
10
- plugins: [
11
- sveltekit(),
12
- ],
13
-
14
- server: {
15
- port: 3000,
16
- allowedHosts: ['engage-moderate-happy-davis.trycloudflare.com'],
17
- },
18
-
19
- test: {
20
- environment: 'happy-dom',
21
- environmentOptions: {
22
- happyDOM: {
23
- settings: {
24
- disableJavaScriptFileLoading: true,
25
- },
26
- },
27
- },
28
- include: ['src/**/*.{test,spec}.{js,ts}'],
29
- setupFiles: ['src/tests/setup.js'],
30
- },
31
-
32
- resolve: {
33
- conditions: process.env.VITEST ? ['browser'] : [],
34
- alias: {
35
- '$lib': path.resolve(__dirname, './src/lib'),
36
- },
37
- },
38
-
39
- define: {
40
- __SCRIPT_VERSION__: JSON.stringify(packageJson.version),
41
- __IS_EDITORIAL_SCRIPT__: true,
42
- },
43
- }))
1
+ import path from 'path'
2
+ import * as dotenv from 'dotenv'
3
+ import { defineConfig } from 'vitest/config'
4
+ import { sveltekit } from '@sveltejs/kit/vite'
5
+ import packageJson from './package.json'
6
+
7
+ dotenv.config({ path: '.env' })
8
+
9
+ export default defineConfig(() => ({
10
+ plugins: [
11
+ sveltekit(),
12
+ ],
13
+
14
+ server: {
15
+ port: 3000,
16
+ allowedHosts: ['engage-moderate-happy-davis.trycloudflare.com'],
17
+ },
18
+
19
+ test: {
20
+ environment: 'happy-dom',
21
+ environmentOptions: {
22
+ happyDOM: {
23
+ settings: {
24
+ disableJavaScriptFileLoading: true,
25
+ },
26
+ },
27
+ },
28
+ include: ['src/**/*.{test,spec}.{js,ts}'],
29
+ setupFiles: ['src/tests/setup.js'],
30
+ },
31
+
32
+ resolve: {
33
+ conditions: process.env.VITEST ? ['browser'] : [],
34
+ alias: {
35
+ '$lib': path.resolve(__dirname, './src/lib'),
36
+ },
37
+ },
38
+
39
+ define: {
40
+ __SCRIPT_VERSION__: JSON.stringify(packageJson.version),
41
+ __IS_EDITORIAL_SCRIPT__: true,
42
+ },
43
+ }))