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

fix: escape vite asset import suffixes #46

Merged
merged 2 commits into from
Dec 6, 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: 2 additions & 0 deletions examples/cloudflare-pages/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { LoaderFunctionArgs } from '@remix-run/cloudflare'
import { useLoaderData } from '@remix-run/react'
import logoDark from '/logo-dark.png?inline'

export const loader = (args: LoaderFunctionArgs) => {
const extra = args.context.extra
Expand All @@ -23,6 +24,7 @@ export default function Index() {
<h4>Extra is {extra}</h4>
<h5>Var in Variables is {myVarInVariables}</h5>
<h6>waitUntil is {isWaitUntilDefined ? 'defined' : 'not defined'}</h6>
<img src={logoDark} alt='Remix' />
</div>
)
}
3 changes: 3 additions & 0 deletions examples/cloudflare-pages/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ test('Should return 200 response - /', async ({ page }) => {

const contentH6 = await page.textContent('h6')
expect(contentH6).toBe('waitUntil is defined')

const imageResponse = await page.goto('/logo-dark.png?inline')
expect(imageResponse?.status()).toBe(200)
})

test('Should return 200 response - /api', async ({ page }) => {
Expand Down
Binary file added examples/cloudflare-pages/public/favicon.ico
Binary file not shown.
Binary file added examples/cloudflare-pages/public/logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/vite-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default (options: Options): Plugin => {
'/assets/**',
'/app/**',
'/src/app/**',
// matches for vite's import assets suffixes
/\?(import(&)?)?(inline|url|no-inline|raw)?$/,
],
injectClientScript: false,
loadModule: async (server, entry) => {
Expand Down
Loading