#vite warning

9 messages · Page 1 of 1 (latest)

weary juniper
#

I am getting a vite warning when i run my astro app . this is my config:

import dotenv from 'dotenv';
dotenv.config();
import { defineConfig } from 'astro/config';
const API_URL = process.env.KIRBY_URL;
const response = await fetch(API_URL + '/global.json');
const data = await response.json();
const defaultLanguage = data.defaultLang.code;
const translations = data.translations.map((lang) => lang.code);

const frontendUrl = data.frontendUrl.endsWith('/')
    ? data.frontendUrl
    : data.frontendUrl + '/';
import tailwind from '@astrojs/tailwind';
import netlify from '@astrojs/netlify/functions';

// https://astro.build/config
export default defineConfig({
    site: frontendUrl,
    i18n:
        translations && translations.length > 0
            ? {
                    defaultLocale: defaultLanguage,
                    locales: [defaultLanguage, ...translations],
                    routing: {
                        prefixDefaultLocale: true,
                    },
              }
            : undefined,
    integrations: [tailwind()],
    image: {
        domains: [API_URL],
    },
    output: process.env.PUBLIC_ENV === 'preview' ? 'server' : 'hybrid',
    adapter: process.env.PUBLIC_ENV === 'preview' ? netlify() : undefined,
});

``
dull bobcatBOT
#

Hi @weary juniper. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the extracts, it's not clear what specific Vite warning you're encountering. However, there are a few common issues that might be causing warnings:

  1. Unsupported Vite Configurations: Astro only partially supports Vite's configuration object. Some properties work, but others are overwritten by Astro, and others are effectively ignored due to how Astro uses Vite internally. It would be good to report warnings when we see you using a Vite configuration property incorrectly. source (https://github.com/withastro/astro/issues/2782)

  2. Environment Variables: If you're trying to use environment variables, you might encounter issues. Astro sees environment variables as system environment variables which aren't statically replaced, they're left as is and evaluated at runtime. Public environment variables work fine because they are statically replaced by Vite. Private envs work during dev only because dotenv loads them from your config file in dev, but the config file isn't shipped in production so it doesn't work in prod. You could use the loadEnv (https://vitejs.dev/guide/api-javascript.html#loadenv) function from Vite to use environment variables in your config file. source (https://github.com/withastro/astro/issues/6025)

  3. Vite Define Config: If you're using vite.define in Astro's defineConfig(), it might not have the desired effect. For example, reading the package.json version from import.meta.env.PKG_VERSION to show it in the Astro app. PKG is properly read from file and parsed but doesn't appear in import.meta.env. It seems that Astro does not support vite.define in Astro's defineConfig(). source (https://github.com/withastro/astro/issues/8967)

#

If you could provide more details about the specific warning you're encountering, it would be easier to provide a more accurate solution.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@weary juniper kapa.ai is still learning and improving, please let us know how it did by reacting below

weary juniper
#

@dull bobcat this is the vite warning:
[WARN] [vite] The glob option "as" has been deprecated in favour of "query". Please updat
e as: 'raw' to query: '?raw', import: 'default'.

dull bobcatBOT
#

Let me check the knowledge base for you. One moment! :books:

#

The warning you're seeing is related to a deprecation in Vite's configuration. The as option in the resolve configuration has been deprecated in favor of query.

To resolve this warning, you should update your Vite configuration from as: 'raw' to query: '?raw', import: 'default'.

However, based on the extracts provided, there's no direct reference to this specific issue in the Astro context. It's recommended to check the official Vite documentation (https://vitejs.dev/config/) or their GitHub repository (https://github.com/vitejs/vite) for more detailed information on handling this deprecation warning.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@weary juniper kapa.ai is still learning and improving, please let us know how it did by reacting below