Created
December 10, 2021 00:37
-
-
Save davidwallacejackson/de8488d2b1dfd0767a8395b76b5c58a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {Plugin} from 'vite'; | |
| import fs from 'fs'; | |
| const index = fs.readFileSync(__dirname + '/index.html', 'utf-8'); | |
| const fileUrls: Plugin = { | |
| name: 'pass-through-file-urls', | |
| configureServer: server => { | |
| server.middlewares.use(async (req, res, next) => { | |
| if (req.url?.match(/.*\/files\/.*$/)) { | |
| res.write(await server.transformIndexHtml(req.url, index)); | |
| res.end(); | |
| return; | |
| } | |
| next(); | |
| }); | |
| }, | |
| }; | |
| export default fileUrls; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment