Problems running applications bundled using Vite
truesteps opened this issue · comments
To Reproduce
Step by step instructions to reproduce the behavior:
- Install sanitize-html with
- Try run project with Vite dev
- Open page
- See error
Expected behavior
A working build with vite
Describe the bug
Seems like V-sanitize implements some functions from the path node library and path uses
process.platform
, meanwhile Vite doesn't send theprocess
into context, it usesimport.meta
. The two attached screenshots showcase the issue, as well as the problem line.
Details
Version of Node.js:
v16.11.1
Server Operating System:
Docker Ubuntu
Additional context:
I'm using sanitize-html within a package called v-sanitize for vue and I wanted to rewrite it to Vue 3 and Vite support.
I updated 2nd step, since Vite only uses esmodules on dev, this only breaks when bundling app for development. When bundling for production, Vite uses rollup, so production builds work as expected.
This looks like a bundling / frontend build issue at the postcss level. You could open a ticket with postcss, or it may be an issue with the way your bundling for frontend use works, but it's not something that can be resolved within sanitize-html.
Excuse me, I meant to say "within sanitize-html."