context method emitFile() is not supported in serve mode. This plugin is likely not vite-compatible.
See original GitHub issueDescribe the bug
I try to use this.emitFile like this
transform() {
const css = sample(allPaths);
this.emitFile({
type: "asset",
source: css,
id: "",
fileName: "atomic.css",
});
},
but emitfile is not generated a d gives warning: context method emitFile() is not supported in serve mode. This plugin is likely not vite-compatible. (In rollup this.emitFile is used with generateBundle instead of transform)
Is there any Changes in vite because I take the reference from rollUp
Reproduction
.
System Info
"vite": "^2.8.1"
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- 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 https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
context method emitFile() is not supported in serve mode. This ...
This is in my svelte.config.js transform() { const css = getAtomicCss(allPaths); this.emitFile({ type: "asset", source: css, ...
Read more >Plugin API - Vite
Virtual modules are a useful scheme that allows you to pass build time information to the source files using normal ESM import syntax....
Read more >rollup ModuleInfo TypeScript Examples - ProgramCreek.com
emitFile is not supported in transform mode. This plugin is likely not compatible`); } else if (source) { fs.writeFileSync(filename, source); } return id; ......
Read more >Troubleshooting | Vite Ruby
If you are using a non-standard setup, try configuring viteBinPath . Your bin/bundle was not generated by Bundler #. It's likely that your...
Read more >Using the VitePWA Plugin for an Offline Site | CSS-Tricks
A service worker is a background process that runs on a separate thread in your web application. Service workers have the ability to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah
emitFile
only works in build mode (where rollup is involved). I’m not sure if it’s possible to callemitFile
in thetransform
hook, maybe that’s the issue. You can try calling it inbuildStart
orgenerateBundle
according to the docs.Is emitting the file required in serve/dev mode? Vite logs a warning as emitting a file in serve mode doesn’t make sense (all files are kept in memory), but it will work in builds as that’s a normal rollup process. If your plugin is for builds only, you can set
apply: 'build'
in your plugin.