Skip to content

Commit 8a4a893

Browse files
authored
Merge pull request #27 from GeekaholicLin/master
add devtools support
2 parents 38abc6e + 1a97c68 commit 8a4a893

File tree

10 files changed

+72
-6
lines changed

10 files changed

+72
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
.env.development.local
1616
.env.test.local
1717
.env.production.local
18+
.history
1819

1920
# secrets
2021
secrets.*.js

src/manifest.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
"icons": {
1515
"128": "icon-128.png"
1616
},
17-
"content_scripts": [{
18-
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
19-
"js": ["contentScript.bundle.js"],
20-
"css": ["content.styles.css"]
21-
}],
17+
"content_scripts": [
18+
{
19+
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
20+
"js": ["contentScript.bundle.js"],
21+
"css": ["content.styles.css"]
22+
}
23+
],
24+
"devtools_page": "devtools.html",
2225
"web_accessible_resources": [
2326
"content.styles.css",
2427
"icon-128.png",

src/pages/Devtools/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title></title>
6+
</head>
7+
8+
<body></body>
9+
</html>

src/pages/Devtools/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chrome.devtools.panels.create('Dev Tools', 'icon-34.png', 'panel.html');

src/pages/Panel/Panel.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
body {
2+
background-color: #242424;
3+
}
4+
5+
.container {
6+
color: #ffffff;
7+
}

src/pages/Panel/Panel.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
3+
import './Panel.css';
4+
5+
const Panel = (): JSX.Element => {
6+
return (
7+
<div className="container">
8+
<h1>Dev Tools Panel</h1>
9+
</div>
10+
);
11+
};
12+
13+
export default Panel;

src/pages/Panel/index.css

Whitespace-only changes.

src/pages/Panel/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>Panel</title>
6+
</head>
7+
8+
<body>
9+
<div id="app-container"></div>
10+
</body>
11+
</html>

src/pages/Panel/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
import { render } from 'react-dom';
3+
4+
import Panel from './Panel';
5+
import './index.css';
6+
7+
render(<Panel />, window.document.querySelector('#app-container'));

webpack.config.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ var options = {
4141
popup: path.join(__dirname, 'src', 'pages', 'Popup', 'index.jsx'),
4242
background: path.join(__dirname, 'src', 'pages', 'Background', 'index.js'),
4343
contentScript: path.join(__dirname, 'src', 'pages', 'Content', 'index.js'),
44+
devtools: path.join(__dirname, 'src', 'pages', 'Devtools', 'index.js'),
45+
panel: path.join(__dirname, 'src', 'pages', 'Panel', 'index.tsx'),
4446
},
4547
chromeExtensionBoilerplate: {
46-
notHotReload: ['contentScript'],
48+
notHotReload: ['contentScript', 'devtools'],
4749
},
4850
output: {
4951
path: path.resolve(__dirname, 'build'),
@@ -172,6 +174,18 @@ var options = {
172174
chunks: ['background'],
173175
cache: false,
174176
}),
177+
new HtmlWebpackPlugin({
178+
template: path.join(__dirname, 'src', 'pages', 'Devtools', 'index.html'),
179+
filename: 'devtools.html',
180+
chunks: ['devtools'],
181+
cache: false,
182+
}),
183+
new HtmlWebpackPlugin({
184+
template: path.join(__dirname, 'src', 'pages', 'Panel', 'index.html'),
185+
filename: 'panel.html',
186+
chunks: ['panel'],
187+
cache: false,
188+
}),
175189
],
176190
infrastructureLogging: {
177191
level: 'info',

0 commit comments

Comments
 (0)