Giter Site home page Giter Site logo

Comments (5)

pengzhanbo avatar pengzhanbo commented on August 24, 2024 1

[vite define] 文档中的描述是 define 的配置, string 值会以原始表达式形式使用,所以如果定义了一个字符串常量,它需要被显式地打引号。(例如使用 JSON.stringify)。 以及 为了与 esbuild 的行为保持一致,表达式必须为一个 JSON 对象(null、boolean、number、string、数组或对象),亦或是一个单独的标识符。

基于文档的说明,所以我没有对 define 传入的配置做特殊的处理。 在我重新阅读了 vite 相关的代码, 在定义的 vite:define 时,对非 string 类型进行了 JSON.stringify 处理。

这里是我没有考虑到的。

from vite-plugin-mock-dev-server.

jiadesen avatar jiadesen commented on August 24, 2024

vite4+vue3

from vite-plugin-mock-dev-server.

jiadesen avatar jiadesen commented on August 24, 2024

vite3 启动报相同的错误..老哥你自测通过了么==、

from vite-plugin-mock-dev-server.

jiadesen avatar jiadesen commented on August 24, 2024
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import mockDevServerPlugin from 'vite-plugin-mock-dev-server'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    mockDevServerPlugin(),
  ],
  server: {
    proxy: {
      '^/api': 'http://example.com/',
    },
  },
})

vue() 删掉就不报错了,这个插件不能跟 @vitejs/plugin-vue 共存?

from vite-plugin-mock-dev-server.

jiadesen avatar jiadesen commented on August 24, 2024

build 参数 define 类型错误引起的,提了个 pr 有时间看看

image

from vite-plugin-mock-dev-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.