Giter VIP home page Giter VIP logo

Comments (14)

hb0730 avatar hb0730 commented on May 22, 2024 1

image
image

这样可以保证loadEnv在任何地方不会抛出process.cwd is not a function

from vue-pure-admin.

hb0730 avatar hb0730 commented on May 22, 2024

当使用vite的LoadEnv时是可行的
image
image

from vue-pure-admin.

xiaoxian521 avatar xiaoxian521 commented on May 22, 2024

你修改这个文件就行了
image

from vue-pure-admin.

hb0730 avatar hb0730 commented on May 22, 2024

还有单独调用loadEnv方法,好像process.cwd()报错了
image

from vue-pure-admin.

xiaoxian521 avatar xiaoxian521 commented on May 22, 2024

并没有呢
image

from vue-pure-admin.

hb0730 avatar hb0730 commented on May 22, 2024

我是在router index.ts中单独调用,发现process.cwd报错,但是在vite.config.ts中调用process.cwd是没有问题的

image
image
image

难道无法再别的地方调用么~~

from vue-pure-admin.

xiaoxian521 avatar xiaoxian521 commented on May 22, 2024

比如你可以这样用:process.env.NODE_ENV

from vue-pure-admin.

xiaoxian521 avatar xiaoxian521 commented on May 22, 2024

别忘了设置这个
image

from vue-pure-admin.

xiaoxian521 avatar xiaoxian521 commented on May 22, 2024

是的,这样是可以的,但是当引入某些第三包时,会出现打包错误

from vue-pure-admin.

hb0730 avatar hb0730 commented on May 22, 2024

3817 有类似案例,仓库地址: vite_vue3_web3

from vue-pure-admin.

hb0730 avatar hb0730 commented on May 22, 2024

好像最终只需要
image
就行了,不需要其他插件

from vue-pure-admin.

xiaoxian521 avatar xiaoxian521 commented on May 22, 2024

好像最终只需要
image
就行了,不需要其他插件

这样打包部署会找不到process 我已经删除了此代码 请检查对你有没有影响

from vue-pure-admin.

hb0730 avatar hb0730 commented on May 22, 2024

好的,在更改之后,我在本地build 部署之后是可以正常运行的,之前这么做是因为dotenv 读取环境变量用到了node相关内置函数,现在应该没有什么影响

from vue-pure-admin.

AdminQQZ avatar AdminQQZ commented on May 22, 2024

image
你们是怎么解决的来着,我没看懂

from vue-pure-admin.

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.