Skip to content

Instantly share code, notes, and snippets.

@brandonb927
Last active May 2, 2024 03:17
Show Gist options
  • Save brandonb927/9ff5fb63d46d33086deb472f764cecb4 to your computer and use it in GitHub Desktop.
Save brandonb927/9ff5fb63d46d33086deb472f764cecb4 to your computer and use it in GitHub Desktop.
Cypress + Typescript ts-loader option `transpileOnly` config helps with memory-contrained machines if you're not running in the Cypress Dashboard but rather using custom Jenkins CI, etc.
module.exports = (on, config) => {
// ...
const wpOptions = webpack.defaultOptions
wpOptions.webpackOptions.resolve = {
extensions: ['.ts', '.js'],
}
wpOptions.webpackOptions.module.rules.push({
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true, // https://github.com/TypeStrong/ts-loader#transpileonly-boolean-defaultfalse
},
},
],
})
on('file:preprocessor', webpack(wpOptions))
// ...
}
@brandonb927
Copy link
Author

@chiptus I don't think this is an issue anymore using recent versions of Cypress, at the time this was a problem in v2 and v3. If that is what you're stuck on, yes you would need to import webpack somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment