forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
81 lines (70 loc) · 1.76 KB
/
webpack.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import _ from 'lodash'
import getCommonConfig, { HtmlWebpackPlugin } from '@packages/web-config/webpack.config.base'
import path from 'path'
import webpack from 'webpack'
const commonConfig = getCommonConfig()
// @ts-ignore
const babelLoader = _.find(commonConfig.module.rules, (rule) => {
// @ts-ignore
return _.includes(rule.use.loader, 'babel-loader')
})
// @ts-ignore
babelLoader.use.options.plugins.push([require.resolve('babel-plugin-prismjs'), {
'languages': ['javascript', 'coffeescript', 'typescript', 'jsx', 'tsx'],
'plugins': ['line-numbers', 'line-highlight'],
'theme': 'default',
'css': false,
}])
let pngRule
// @ts-ignore
const nonPngRules = _.filter(commonConfig.module.rules, (rule) => {
// @ts-ignore
if (rule.test.toString().includes('png')) {
pngRule = rule
return false
}
return true
})
pngRule.use[0].options = {
name: '[name].[ext]',
outputPath: 'img',
publicPath: '/__cypress/runner/img/',
}
// @ts-ignore
const config: webpack.Configuration = {
...commonConfig,
module: {
rules: [
...nonPngRules,
pngRule,
],
},
entry: {
cypress_runner: [path.resolve(__dirname, 'src/index.js')],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
}
// @ts-ignore
config.plugins = [
// @ts-ignore
...config.plugins,
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './static/index.html'),
inject: false,
}),
]
config.resolve = {
...config.resolve,
alias: {
'bluebird': require.resolve('bluebird'),
'lodash': require.resolve('lodash'),
'mobx': require.resolve('mobx'),
'mobx-react': require.resolve('mobx-react'),
'react': require.resolve('react'),
'react-dom': require.resolve('react-dom'),
},
}
export default config