Created
March 11, 2022 07:29
-
-
Save mscolnick/9ad3094391c1faa0afbbfcdd6e116f49 to your computer and use it in GitHub Desktop.
Plugin js for vite + cypress
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
const path = require('path'); | |
const { createServer } = require('vite'); | |
module.exports = async (on, config) => { | |
const host = process.env.HOST || 'localhost'; | |
const port = process.env.PORT || 3000; | |
// Vite config | |
const viteConfig = { | |
configFile: path.resolve(__dirname, "../vite.config.ts"), | |
root: path.resolve(__dirname, ".."), | |
server: { | |
host: host, | |
port: port, | |
}, | |
}; | |
// Start vite server | |
const server = await createServer(viteConfig); | |
await server.listen(); | |
server.printUrls(); | |
// Cypress config | |
config.baseUrl = `http://${host}:${port}`; | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment