-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(options): add multiple
openPage
support (#2266)
- Loading branch information
1 parent
06e014b
commit c9e9178
Showing
12 changed files
with
265 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# CLI: Open Page Option (Multiple) | ||
|
||
```console | ||
npm run webpack-dev-server -- --open-page example1.html,example2.html | ||
``` | ||
|
||
Some applications may consist of multiple pages. During development it may | ||
be useful to directly open multiple pages at the same time. The pages to open | ||
may be specified as the argument to the `open-page` option. | ||
|
||
## What Should Happen | ||
|
||
The script should open `http://localhost:8080/example1.html` and | ||
`http://localhost:8080/example2.html` in your default browser. | ||
You should see the text on the page itself change to read `Success!`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const target = document.querySelector('#target'); | ||
|
||
if (window.location.href.endsWith('example1.html')) { | ||
target.classList.add('pass'); | ||
target.innerHTML = 'Success!'; | ||
} else { | ||
target.classList.add('fail'); | ||
target.innerHTML = 'Houston, we have a problem.'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const target = document.querySelector('#target'); | ||
|
||
if (window.location.href.endsWith('example2.html')) { | ||
target.classList.add('pass'); | ||
target.innerHTML = 'Success!'; | ||
} else { | ||
target.classList.add('fail'); | ||
target.innerHTML = 'Houston, we have a problem.'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
// our setup function adds behind-the-scenes bits to the config that all of our | ||
// examples need | ||
const { setup } = require('../../util'); | ||
|
||
module.exports = [ | ||
setup({ | ||
context: __dirname, | ||
entry: './app1.js', | ||
output: { | ||
filename: 'app1.js', | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
filename: 'example1.html', | ||
template: '../../.assets/layout.html', | ||
title: 'Open Page (Multiple) / Example / Page 1', | ||
}), | ||
], | ||
}), | ||
setup({ | ||
context: __dirname, | ||
entry: './app2.js', | ||
output: { | ||
filename: 'app2.js', | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
filename: 'example2.html', | ||
template: '../../.assets/layout.html', | ||
title: 'Open Page (Multiple) / Example / Page 2', | ||
}), | ||
], | ||
}), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`runOpen util on specify multiple absolute https URLs with pages in Google Chrome 1`] = ` | ||
Array [ | ||
"https://example2.com", | ||
Object { | ||
"app": "Google Chrome", | ||
"wait": false, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`runOpen util on specify multiple absolute https URLs with pages in Google Chrome 2`] = ` | ||
Array [ | ||
"https://example3.com", | ||
Object { | ||
"app": "Google Chrome", | ||
"wait": false, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`runOpen util on specify one relative URL and one absolute URL with pages in Google Chrome 1`] = ` | ||
Array [ | ||
"https://example.com/index.html", | ||
Object { | ||
"app": "Google Chrome", | ||
"wait": false, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`runOpen util on specify one relative URL and one absolute URL with pages in Google Chrome 2`] = ` | ||
Array [ | ||
"https://example2.com", | ||
Object { | ||
"app": "Google Chrome", | ||
"wait": false, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`runOpen util should open browser on specify URL with multiple pages inside array 1`] = ` | ||
Array [ | ||
"https://example.com/index.html", | ||
Object { | ||
"wait": false, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`runOpen util should open browser on specify URL with multiple pages inside array 2`] = ` | ||
Array [ | ||
"https://example.com/index2.html", | ||
Object { | ||
"wait": false, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`runOpen util should open browser on specify URL with page inside array 1`] = ` | ||
Array [ | ||
"https://example.com/index.html", | ||
Object { | ||
"wait": false, | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters