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
I've been trying to migrate my MUI-based React app to Vite and I've already found something that successfully generates a minimized production ready js file. Now I've been working on a dev-time configuration, but for that I want Vite only to periodically output non-optimized JS file to a designated folder. By "periodically" I mean "on every change to any of the source files". Also, I don't need Vite's dev server, as I want my JS file to be hosted on my .NET app.
Here's the vite.config.js I've come up so far
import{defineConfig}from'vite'importreactfrom'@vitejs/plugin-react';exportdefaultdefineConfig({base: "/",plugins: [react()],define: {'process.env.NODE_ENV': JSON.stringify('production'),'process.env.REACT_APP_CLIENT': JSON.stringify('true'),},build: {outDir: "../myIISServer/wwwroot",emptyOutDir: true,rollupOptions: {input: "src/index.tsx",output: {entryFileNames: "main.min.js",},onwarn(warning,warn){// Suppress "Module level directives cause errors when bundled" warningsif(warning.code==="MODULE_LEVEL_DIRECTIVE")return;// Suppress "A comment /*#__PURE__*/" contains an annotation... " warningsif(warning.code==="INVALID_ANNOTATION")return;warn(warning);},}}})
No issue with release - it works just fine.
Regarding dev - it successfully generates the first version of the file, but then on any modification of any of the source files it fails with the following error message:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've been trying to migrate my MUI-based React app to Vite and I've already found something that successfully generates a minimized production ready js file. Now I've been working on a dev-time configuration, but for that I want Vite only to periodically output non-optimized JS file to a designated folder. By "periodically" I mean "on every change to any of the source files". Also, I don't need Vite's dev server, as I want my JS file to be hosted on my .NET app.
Here's the
vite.config.js
I've come up so farIn my
package.json
I've defined two scripts:No issue with
release
- it works just fine.Regarding
dev
- it successfully generates the first version of the file, but then on any modification of any of the source files it fails with the following error message:I've tried running it with
$env:DEBUG="vite:*"; npm run dev
but that didn't provide any extra diagnostic info.My questions:
Versions I'm using:
Beta Was this translation helpful? Give feedback.
All reactions