Skip to content

Commit

Permalink
add devtools support. Fixed lxieyang#17
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekaholicLin committed Jan 5, 2021
1 parent 7b14206 commit ecb9b11
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.env.development.local
.env.test.local
.env.production.local
.history

# secrets
secrets.*.js
13 changes: 8 additions & 5 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
"icons": {
"128": "icon-128.png"
},
"content_scripts": [{
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
"js": ["contentScript.bundle.js"],
"css": ["content.styles.css"]
}],
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
"js": ["contentScript.bundle.js"],
"css": ["content.styles.css"]
}
],
"devtools_page": "devtools.html",
"web_accessible_resources": [
"content.styles.css",
"icon-128.png",
Expand Down
9 changes: 9 additions & 0 deletions src/pages/Devtools/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title></title>
</head>

<body></body>
</html>
1 change: 1 addition & 0 deletions src/pages/Devtools/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chrome.devtools.panels.create('Dev Tools', 'icon-34.png', 'panel.html');
7 changes: 7 additions & 0 deletions src/pages/Panel/Panel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
body {
background-color: #242424;
}

.container {
color: #ffffff;
}
13 changes: 13 additions & 0 deletions src/pages/Panel/Panel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

import './Panel.css';

const Panel = (): JSX.Element => {
return (
<div className="container">
<h1>Dev Tools Panel</h1>
</div>
);
};

export default Panel;
Empty file added src/pages/Panel/index.css
Empty file.
11 changes: 11 additions & 0 deletions src/pages/Panel/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Panel</title>
</head>

<body>
<div id="app-container"></div>
</body>
</html>
7 changes: 7 additions & 0 deletions src/pages/Panel/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import { render } from 'react-dom';

import Panel from './Panel';
import './index.css';

render(<Panel />, window.document.querySelector('#app-container'));
16 changes: 15 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ var options = {
popup: path.join(__dirname, 'src', 'pages', 'Popup', 'index.jsx'),
background: path.join(__dirname, 'src', 'pages', 'Background', 'index.js'),
contentScript: path.join(__dirname, 'src', 'pages', 'Content', 'index.js'),
devtools: path.join(__dirname, 'src', 'pages', 'Devtools', 'index.js'),
panel: path.join(__dirname, 'src', 'pages', 'Panel', 'index.tsx'),
},
chromeExtensionBoilerplate: {
notHotReload: ['contentScript'],
notHotReload: ['contentScript', 'devtools'],
},
output: {
path: path.resolve(__dirname, 'build'),
Expand Down Expand Up @@ -172,6 +174,18 @@ var options = {
chunks: ['background'],
cache: false,
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'pages', 'Devtools', 'index.html'),
filename: 'devtools.html',
chunks: ['devtools'],
cache: false,
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'pages', 'Panel', 'index.html'),
filename: 'panel.html',
chunks: ['panel'],
cache: false,
}),
],
infrastructureLogging: {
level: 'info',
Expand Down

0 comments on commit ecb9b11

Please sign in to comment.