You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unexpected token (Note that you need plugins to import files that are not JavaScript)
file: E:/project-dir/src/config/index.ts:46:42
44: };
45: const ENV = import.meta.env.VITE_BUILD_ENV ||"production"
46: console.log("import.meta.env.VITE_BUILD_ENV", ENV)
^
47: export default config[ENV as "production"||"production"];
error during build:
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
at error (file:///E:/project-dir/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
at Module.error (file:///E:/project-dir/node_modules/rollup/dist/es/shared/rollup.js:12429:16)
at Module.tryParse (file:///E:/project-dir/node_modules/rollup/dist/es/shared/rollup.js:12806:25)
at Module.setSource (file:///E:/project-dir/node_modules/rollup/dist/es/shared/rollup.js:12711:24)
at ModuleLoader.addModuleSource (file:///E:/project-dir/node_modules/rollup/dist/es/shared/rollup.js:22153:20)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Describe the bug
.env
file:config.ts
when run
vue-tsc --noEmit && vite build --mode production
,the result is:It is worked very good when use
vite --host
in develop mode;when I look up then build asset, it is like this:
However in
webpack
, usewebpack.DefinePlugin
:The result is:
Reproduction
https://stackblitz.com/edit/vitejs-vite-yvjegt?file=dist/assets/index.60209a92.js
Steps to reproduce
Run
npm install
Run
npm run build
System Info
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: