vendure-ecommerce / storefront-qwik-starter

An e-commerce storefront starter built with Qwik and Vendure
https://qwik-storefront.vendure.io
227 stars 86 forks source link

Hot Reload not working in this Qwik project with Vite dev server #162

Closed yohamta closed 2 months ago

yohamta commented 2 months ago

Description

I'm experiencing issues with hot reloading in my Qwik project. When I make changes to my code, the changes are not automatically reflected in the browser even with manually reloading the page. It only will be reflected after stop/restart with npm run dev.

Environment

Steps to Reproduce

  1. Clone the storefront-qwik-starter project
  2. Run npm install
  3. Run npm run dev
  4. Make changes to any component file
  5. Observe that changes are not reflected in the browser even with manual reload

Expected Behavior

Changes made to the code should be automatically reflected in the browser without needing to manually reload the page.

Actual Behavior

Changes are not reflected in the browser until the page is manually reloaded.

Additional Context

package.json (Nothing is changed)

{
    "name": "storefront-qwik-starter",
    "description": "A headless commerce storefront starter kit built with Vendure & Qwik",
    "homepage": "https://qwik.builder.io/",
    "license": "",
    "private": true,
    "type": "module",
    "engines": {
        "node": ">=16"
    },
    "scripts": {
        "build": "qwik build",
        "build.client": "vite build && npm run i18n-translate",
        "build.preview": "vite build --ssr src/entry.preview.tsx",
        "build.server": "vite build -c adapters/cloudflare-pages/vite.config.ts",
        "build.types": "tsc --incremental --noEmit",
        "deploy": "wrangler pages dev ./dist",
        "develop": "concurrently pnpm:dev pnpm:dev.server",
        "dev": "vite --mode ssr --port 8080",
        "dev.server": "cd one-click-deploy && yarn dev",
        "dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
        "fmt": "prettier --write .",
        "fmt.check": "prettier --check .",
        "i18n-extract": "node_modules/.bin/localize-extract -s \"dist/build/*.js\" -f json -o src/locales/message.en.json",
        "i18n-translate": "node_modules/.bin/localize-translate -s \"*.js\" -t src/locales/message.*.json -o dist/build/{{LOCALE}} -r ./dist/build",
        "i18n-sort": "ts-node --project scripts/tsconfig.scripts.json scripts/sort-i18n.ts src/locales",
        "lint": "eslint \"src/**/*.ts*\"",
        "prepare": "husky install",
        "preview": "qwik build preview && vite preview --open",
        "start": "pnpm generate && vite --open --mode ssr",
        "qwik": "qwik",
        "generate-admin": "graphql-codegen --config codegen-admin.ts",
        "generate-shop": "graphql-codegen --config codegen-shop.ts",
        "generate-dev": "export IS_DEV=TRUE && pnpm generate-shop && pnpm generate-admin",
        "generate-local": "export IS_LOCAL=TRUE && pnpm generate-shop && pnpm generate-admin",
        "generate": "pnpm generate-shop && pnpm generate-admin"
    },
    "devDependencies": {
        "@angular/compiler": "^17.1.3",
        "@angular/compiler-cli": "^17.1.3",
        "@builder.io/qwik": "1.7.3",
        "@builder.io/qwik-city": "1.7.3",
        "@builder.io/qwik-labs": "github:BuilderIo/qwik-labs-build#36582dc0",
        "@graphql-codegen/cli": "^5.0.2",
        "@graphql-codegen/introspection": "^4.0.2",
        "@graphql-codegen/typescript": "^4.0.4",
        "@graphql-codegen/typescript-operations": "^4.1.2",
        "@tailwindcss/forms": "^0.5.7",
        "@types/braintree-web-drop-in": "^1.39.3",
        "@types/eslint": "8.56.2",
        "@types/node": "20.11.17",
        "@typescript-eslint/eslint-plugin": "7.0.1",
        "@typescript-eslint/parser": "7.0.1",
        "autoprefixer": "10.4.17",
        "concurrently": "8.2.2",
        "eslint": "8.57.0",
        "eslint-plugin-qwik": "1.7.3",
        "husky": "^9.0.10",
        "node-fetch": "3.3.2",
        "postcss": "8.4.35",
        "prettier": "3.2.5",
        "pretty-quick": "^4.0.0",
        "tailwindcss": "3.4.1",
        "typescript": "5.3.3",
        "undici": "6.6.2",
        "vite": "5.1.1",
        "vite-tsconfig-paths": "4.3.1",
        "wrangler": "3.28.1"
    },
    "dependencies": {
        "@angular/localize": "^17.1.3",
        "@graphql-codegen/typescript-generic-sdk": "^4.0.1",
        "@stripe/stripe-js": "^3.0.0",
        "braintree-web-drop-in": "^1.42.0",
        "graphql": "^16.8.1",
        "graphql-tag": "^2.12.6",
        "qwik-image": "^0.0.8",
        "zod": "^3.22.4"
    },
    "overrides": {
        "@angular/compiler-cli": {
            "typescript": "5.3.3"
        }
    }
}

vite.config.ts (Nothing is changed)

import { qwikCity } from '@builder.io/qwik-city/vite';
import { qwikInsights } from '@builder.io/qwik-labs/vite';
import { qwikVite } from '@builder.io/qwik/optimizer';
import { defineConfig, loadEnv } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineConfig(async (config) => {
    return {
        // Enable to analyze via source-map-explorer
        ssr: { target: 'webworker' },
        build: {
            sourcemap: config.mode === 'development',
        },
        plugins: [
            qwikInsights({
                publicApiKey: loadEnv('', '.', '').VITE_QWIK_INSIGHTS_KEY,
            }),
            qwikCity(),
            qwikVite(),
            tsconfigPaths(),
        ],
        preview: {
            headers: {
                'Cache-Control': 'public, max-age=600',
            },
        },
    };
});

I've already tried:

Any help or guidance would be greatly appreciated. Thank you!

gioboa commented 2 months ago

Hi @yohamta thanks for your report. This is a Qwik issue, it's tracked here. So I close this one, let's continue there. Thanks