Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 18bd227

Browse files
committed
improve readme
1 parent 7594522 commit 18bd227

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

README.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,23 @@ module.exports = (on) => {
3838

3939
### browserifyOptions
4040

41-
Object of options passed to [browserify](https://github.com/browserify/browserify#browserifyfiles--opts).
41+
Object of options passed to [browserify](https://github.com/browserify/browserify#browserifyfiles--opts).
4242

43-
If you pass one of these top-level options in, it will override the default. So if pass `extensions: ['.cljs']`, the default extensions (`js, jsx, coffee, cjsx`) will no longer be supported. If you wish to add to the supported extensions, read up on [modifying the default options](#modifying-default-options).
43+
```javascript
44+
// example
45+
browserify({
46+
browserifyOptions: {
47+
extensions: ['.js', '.ts'],
48+
plugin: [
49+
['tsify']
50+
]
51+
}
52+
})
53+
```
54+
55+
If you pass one of the top-level options in (`extensions`, `transform`, etc), it will override the default. In the above example, browserify will process `.js` and `.ts` files, but not `.jsx`, `.coffee`, or `.cjsx`. If you wish to add to or modify existing options, read about [modifying the default options](#modifying-default-options).
4456

45-
As long as the config passed from Cypress indicates that the plugin should watch files, [watchify](https://github.com/browserify/watchify) is automatically configured as a plugin, so there's no need to manually specify it.
57+
[watchify](https://github.com/browserify/watchify) is automatically configured as a plugin (as needed), so it's not necessary to manually specify it.
4658

4759
**Default**:
4860

@@ -52,28 +64,37 @@ As long as the config passed from Cypress indicates that the plugin should watch
5264
transform: [
5365
[
5466
'cjsxify',
55-
{},
67+
{}
5668
],
5769
[
5870
'babelify',
5971
{
6072
ast: false,
6173
babelrc: false,
6274
plugins: ['babel-plugin-add-module-exports'],
63-
presets: ['babel-preset-env', 'babel-preset-react'],
75+
presets: ['babel-preset-env', 'babel-preset-react']
6476
},
65-
],
77+
]
6678
],
6779
plugin: [],
6880
cache: {},
69-
packageCache: {},
81+
packageCache: {}
7082
}
7183
```
7284

7385
### watchifyOptions
7486

7587
Object of options passed to [watchify](https://github.com/browserify/watchify#options)
7688

89+
```javascript
90+
// example
91+
browserify({
92+
watchifyOptions: {
93+
delay: 500
94+
}
95+
})
96+
```
97+
7798
**Default**:
7899

79100
```javascript
@@ -84,7 +105,7 @@ Object of options passed to [watchify](https://github.com/browserify/watchify#op
84105
'**/.sass-cache/**',
85106
'**/bower_components/**',
86107
'**/coverage/**',
87-
'**/node_modules/**',
108+
'**/node_modules/**'
88109
],
89110
}
90111
```
@@ -94,6 +115,7 @@ Object of options passed to [watchify](https://github.com/browserify/watchify#op
94115
A function that is called with the [browserify bundle](https://github.com/browserify/browserify#browserifyfiles--opts). This allows you to specify external files and plugins. See the [browserify docs](https://github.com/browserify/browserify#baddfile-opts) for methods available.
95116

96117
```javascript
118+
// example
97119
browserify({
98120
onBundle (bundle) {
99121
bundle.external('react')
@@ -115,7 +137,7 @@ const browserify = require('@cypress/browserify-preprocessor')
115137

116138
module.exports = (on) => {
117139
const options = browserify.defaultOptions
118-
options.transforms[1].options.babelrc = true
140+
options.transform[1][1].options.babelrc = true
119141

120142
on('file:preprocessor', browserify(options))
121143
}

0 commit comments

Comments
 (0)