Skip to content

Instantly share code, notes, and snippets.

@brandonb927
Last active June 28, 2022 18:05
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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))
// ...
}
@chiptus
Copy link

chiptus commented Jun 28, 2022

where does webpack comes from? should I do const webpack = require('webpack')?

@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