antfu-collective / vite-ssg

Static site generation for Vue 3 on Vite
MIT License
1.35k stars 136 forks source link

My production builds are going to dev mode #330

Open xrayian opened 1 year ago

xrayian commented 1 year ago

Describe the bug

I was checking my production code in chrome dev tools and noticed that the Vue extension was enabled and showing all the details.

my vite.config.ts

import { fileURLToPath, URL } from "url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import ssgOptions from "vite-ssg";
import generateSitemap from "vite-ssg-sitemap";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  build: {
    manifest: true,
    minify: "esbuild", 
  },
  ssgOptions: {
    mock: true,
    script: "async",
    formatting: "minify",
    onFinished() {
      generateSitemap();
    },
  },
});

Am I doing anything wrong here?

I'm building with npm run dev which runs npx vue-tsc --noEmit && vite-ssg build

Reproduction

will add

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (6) x64 AMD Ryzen 5 3500X 6-Core Processor
    Memory: 8.15 GB / 15.95 GB
  Binaries:
    Node: 18.4.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.3.0 - D:\<PROJECT>\node_modules\.bin\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.755.0), Chromium (109.0.1518.70)
    Internet Explorer: 11.0.22621.1

Used Package Manager

npm

Validations

xrayian commented 1 year ago

Found a discussion thread about this #329 . closing this now

UPDATE: THE DISCUSSION THREAD IS STALE

Mini-Sylar commented 1 year ago

Leaving my solution here as well

modify your "build" script to explicitly set node to production mode

Windows

 "build": "set NODE_ENV=production&& vite-ssg build",

Linux

  "build": "export NODE_ENV=production && vite-ssg build",