AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题

问题[vite](coding)

Martin Hope
Becca
Asked: 2025-04-21 20:14:00 +0800 CST

如何在 Tailwind v4(react-vite)中使用环境变量?

  • 6

在我目前的工作中,我们使用 .env 变量来设置网页的主颜色。我一直在使用新的 Tailwind 设置,在 index.css 中定义所有内容,但我还没有找到直接在其中使用环境变量的方法。

我的 index.css 可以工作,但不是我想要的

@import "tailwindcss";

@theme{
  --color-main:#62297f;
  --color-secondary:#5184c9;
}

我的 .env

VITE_PRIMARY_COLOR=#3490dc
VITE_SECONDARY_COLOR=#ffed4a
VITE_ACTION_COLOR=#e3342f
vite
  • 1 个回答
  • 22 Views
Martin Hope
wortwart
Asked: 2025-01-07 00:20:55 +0800 CST

Vite 项目的 Podman 构建失败

  • 6

我们基于 Vite 的前端项目在后端使用 Docker 运行。在发布过程中,Podman 运行自动化npm install和npm run build命令。

最近,Podman 构建失败。其中一个第三方脚本 (html2pdf.js / jspdf) 转译错误。

原文来自 jspdf.es.js:

case 0:
case false:
case "fill":

当我们在本地构建它时它是这样的:

switch(P){case 0:case!1:case"fill":

但 Podman 将其编译为:

switch(P){case 0:casefalse:case"fill":

... 它崩溃并显示来自 vite:esbuild-transpile 的错误消息。

我们在本地机器上尝试了不同的 Node 版本,并在 npm 和 yarn 之间切换,但无法重现此错误。使用 Podman,我们无法获得任何正确的构建 - 甚至使用以前可以使用的旧代码版本也无法获得正确的构建。

有什么想法可以改变 Podman 的构建选项吗?或者只是使用节点模块附带的预编译 html2pdf.min.js?

vite
  • 1 个回答
  • 115 Views
Martin Hope
opensas
Asked: 2024-12-21 00:09:20 +0800 CST

SvelteKit:使用 vitest 时出现“没有与此调用匹配的过载”错误invite.config.js

  • 5

我刚刚创建了一个应用程序pnpx sv create sveltekit-test2

并检查了 vitest

现在当我运行时pnpm check出现此错误:

Loading svelte-check in workspace: /home/sas/devel/apps/dgiit/proyectos/tmp/sveltekit-test
Getting Svelte diagnostics...

/home/sas/devel/apps/dgiit/proyectos/tmp/sveltekit-test/vite.config.ts:5:12
Error: No overload matches this call.
  The last overload gave the following error.

这是我的 vite.config.js

import { defineConfig } from "vitest/config";
import { sveltekit } from '@sveltejs/kit/vite';

export default defineConfig({
    plugins: [sveltekit()],

    test: {
        include: ['src/**/*.{test,spec}.{js,ts}']
    }
});

vscode 上也出现了同样的错误

在此处输入图片描述

顺便说一下,包中defineConfig的功能可以正常工作vite

在此处输入图片描述

vite
  • 1 个回答
  • 15 Views
Martin Hope
Sventies
Asked: 2024-11-19 04:35:47 +0800 CST

Remix Vite 应用中 React Router Future Flag 警告

  • 7

我正在使用 Remix 和现代npx create-remix@latest(cloudflare) 模板。它在底层使用 React 路由器 (Remix 也使用),但我在代码中没有明确使用 React 路由器。

现在我收到此警告:

⚠️ React Router Future Flag Warning: The revalidation behavior after 4xx/5xx `action` responses is changing in v7. You can use the `v7_skipActionErrorRevalidation` future flag to opt-in early. For more information, see [https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation][1].

单击链接会给我提供有关如何编辑组件以解决此问题的建议,但我的应用程序中没有这样的组件。

以下是我的(相关)未决事项:

"@remix-run/cloudflare": "^2.11.1",
"@remix-run/cloudflare-pages": "^2.11.1",
"@remix-run/react": "^2.11.1",
"remix-utils": "^7.6.0",

我该怎么做才能让这些警告日志消失/解决这个问题?

vite
  • 2 个回答
  • 104 Views
Martin Hope
jukenduit
Asked: 2024-04-23 04:51:47 +0800 CST

使用 RTK 查询和 vite 的代理问题

  • 5

我开始使用Vite而不是CRA但我无法让代理工作。

我正在使用json server我的数据库,它位于http://localhost:3000/customers

使用 CRA,我会在 apiSlice 中"proxy": "http://localhost:3000",添加:package.json

const baseQuery = fetchBaseQuery({ baseUrl: "" });

然而这不适用于 Vite,所以我尝试将其添加到vite.config:

server: {
        proxy: {
            "/api": "http://localhost:3000",
        },
    },

并将我的更改baseQuery为:

const baseQuery = fetchBaseQuery({ baseUrl: "/api" });

但是我不断在控制台中收到此错误:

CustomerList.jsx:4 Uncaught TypeError: useGetCustomersQuery is not a function or its return value is not iterable

useGetCustomersQuery是我的 RTK 查询,我相信问题在于它没有与backend应有的方式进行通信。

vite
  • 1 个回答
  • 13 Views
Martin Hope
Mikko Ohtamaa
Asked: 2024-04-20 22:25:01 +0800 CST

意外的标记“,”。预期的标识符或字符串

  • 5

当我运行 SvelteKit vite 开发服务器时,npm run dev尝试打开页面时出现错误:

RollupError: Unexpected token `,`. Expected identifier or string
    at getRollupError (file:///Users/moo/code/frentek/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
    at ParseError.initialise (file:///Users/moo/code/frentek/node_modules/rollup/dist/es/shared/node-entry.js:11170:28)
    at convertNode (file:///Users/moo/code/frentek/node_modules/rollup/dist/es/shared/node-entry.js:12915:10)
    at convertProgram (file:///Users/moo/code/frentek/node_modules/rollup/dist/es/shared/node-entry.js:12232:12)
    at Module.setSource (file:///Users/moo/code/frentek/node_modules/rollup/dist/es/shared/node-entry.js:14076:24)
    at async ModuleLoader.addModuleSource (file:///Users/moo/code/frentek/node_modules/rollup/dist/es/shared/node-entry.js:18729:13)

在此输入图像描述

但Vite并没有透露问题出在哪里。

同样的错误消息没有npm run build更多信息。

如何找到有解析错误的有问题的 Svelte 文件?

vite
  • 1 个回答
  • 15 Views
Martin Hope
monik rayu
Asked: 2024-03-30 16:31:53 +0800 CST

我正在尝试将 Context api 用于 vite 中的待办事项网站,但不知何故它不起作用

  • 5

这是我的 Usercontext.js


import React from "react";

const Usercontext = React.createContext();

export default Usercontext;

这是我的 Usercontextprovider.jsx

import React, {  useState } from "react";
import Usercontext from "./usercontext";

const Usercontextprovider = ({children})=>{
    let [user,Setuser] = useState(null);
    <Usercontext.Provider value={{user,Setuser}}>
        {children}
    </Usercontext.Provider>
}
export default Usercontextprovider;

这是我的 Addtodo.jsx

import { useEffect, useState ,useContext} from "react";
import Usercontext from "./context/usercontext";

export default function Addtodo(){
    let [options,setoptions] = useState([]);
    let id = 1;
    let {setuser} = useContext(Usercontext);
    return(
        <>
        <input type="text" placeholder="ADD TO DO" defaultValue={''} className="border rounded-l-lg w-64 h-6 text-black" id='todo'/>
        <button className="bg-orange-500 rounded-r-lg" onClick={()=>{
            let todo = document.querySelector("#todo").value;
                options.push({
                    'id':id,
                    'tick':false,
                    'edit':false,
                    'todo':{todo}
                });
                setuser({options});
                id++;
                document.querySelector('#todo').value = '';
        }}>ADD</button>
        </>
    )
}

这是我的 app.jsx

import Addtodo from './Addtodo'
import Usercontextprovider from './context/usercontextprovider'
import List from './List'
function App() {
  return (
    <Usercontextprovider>
        <h1>Hello</h1>
        <Addtodo />
    </Usercontextprovider>
  )
}

导出默认应用程序;

我的网页现在是空的,根目录中没有元素,我更希望它有 Addtodo.jsx,但它是空的

vite
  • 1 个回答
  • 28 Views
Martin Hope
RCKT
Asked: 2023-12-25 17:19:02 +0800 CST

如何在`dev`中调试`vite-plugin-static-copy`转换函数?

  • 5

我刚刚从 webpack 转移过来copyWebpackPlugin,并且无法理解如何调试这个插件的代码。

这是我的vite.config.ts

import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';
import ssr from 'vike/plugin';
import { viteStaticCopy } from 'vite-plugin-static-copy'

export default defineConfig({
  plugins: [
    preact(),
    ssr({ prerender: true }),
    viteStaticCopy({
      targets: [
        {
          src: 'public/assets/icons/favicon.svg', // this is a placeholder string, so we have this script to be executed once
          dest: `path/to/dir`,
          rename: 'filename.pdf',
          transform: {
            encoding: 'buffer',
            handler: async (_content, path) => {
              console.log(1)
              try {
                const response = await fetch(URL)
                const json = await response.json()

                console.log(json)
    
                return await processJson(json)
              } catch (e) {
                console.log(path)
                console.log(e)
              }
            },
          },
        }
      ]
    })
  ],
});

而在里面,包括在内,npm run dev都没有被打印出来。我唯一看到的是console.logviteStaticCopyprocessJson[vite-plugin-static-copy] Collected 1 items.

我怎样才能解决这个问题?

vite
  • 1 个回答
  • 29 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve