Skip to content

Instantly share code, notes, and snippets.

@mscolnick
Created March 11, 2022 07:29
Show Gist options
  • Save mscolnick/9ad3094391c1faa0afbbfcdd6e116f49 to your computer and use it in GitHub Desktop.
Save mscolnick/9ad3094391c1faa0afbbfcdd6e116f49 to your computer and use it in GitHub Desktop.
Plugin js for vite + cypress
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