2022-03-30 05:49:41 -04:00
|
|
|
module.exports = (on, config) => {
|
|
|
|
if (config.testingType === 'component') {
|
|
|
|
const { startDevServer } = require('@cypress/webpack-dev-server')
|
2022-04-06 05:59:13 -04:00
|
|
|
const { merge } = require('webpack-merge')
|
2022-03-30 05:49:41 -04:00
|
|
|
const path = require('path')
|
2022-04-06 06:14:43 -04:00
|
|
|
const webpack = require('webpack')
|
2022-03-30 05:49:41 -04:00
|
|
|
const devConfig = require('../../webpack.config.dev')
|
|
|
|
|
|
|
|
const webpackConfig = merge(devConfig, {
|
|
|
|
devServer: {
|
2022-04-06 06:14:43 -04:00
|
|
|
static: path.join(__dirname, '../../public'),
|
2022-03-30 05:49:41 -04:00
|
|
|
},
|
2022-04-06 05:59:13 -04:00
|
|
|
stats: 'none',
|
2022-04-06 06:14:43 -04:00
|
|
|
plugins: [
|
|
|
|
new webpack.EnvironmentPlugin({
|
|
|
|
CYPRESS: true,
|
|
|
|
}),
|
|
|
|
],
|
2022-03-30 05:49:41 -04:00
|
|
|
})
|
|
|
|
|
2022-04-06 05:59:13 -04:00
|
|
|
delete webpackConfig.devServer.client
|
|
|
|
|
2022-04-06 06:14:43 -04:00
|
|
|
webpackConfig.entry = {}
|
|
|
|
const addWorker = (name, importPath) => {
|
|
|
|
webpackConfig.entry[name] = require.resolve(importPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
// add entrypoint under '/' for latex-linter worker
|
|
|
|
addWorker(
|
|
|
|
'latex-linter-worker',
|
|
|
|
'../../modules/source-editor/frontend/js/languages/latex/linter/latex-linter.worker.js'
|
|
|
|
)
|
|
|
|
|
|
|
|
// add entrypoints under '/' for pdfjs workers
|
|
|
|
const pdfjsVersions = ['pdfjs-dist210', 'pdfjs-dist213']
|
|
|
|
for (const name of pdfjsVersions) {
|
|
|
|
addWorker(name, `${name}/legacy/build/pdf.worker.js`)
|
|
|
|
}
|
|
|
|
|
2022-03-30 05:49:41 -04:00
|
|
|
on('dev-server:start', options => {
|
|
|
|
return startDevServer({ options, webpackConfig })
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|