get rid of HtmlWebpackPlugin

This commit is contained in:
Dima Gerasimov 2020-02-14 23:07:50 +00:00
parent 08d316a1de
commit 8a9c64a25c
7 changed files with 21 additions and 53 deletions

View file

@ -31,6 +31,7 @@ def get_webdriver():
driver.install_addon(str(addon_path), temporary=True) driver.install_addon(str(addon_path), temporary=True)
yield driver yield driver
finally: finally:
# confirm('ready to continue?')
driver.close() driver.close()

View file

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>

View file

@ -47,6 +47,7 @@ function refreshPermissionValidation(endpoint: string) {
} }
function restoreOptions() { function restoreOptions() {
getSaveButton().addEventListener('click', saveOptions);
get_options(opts => { get_options(opts => {
const ep = opts.endpoint; const ep = opts.endpoint;
getEndpoint().value = ep; getEndpoint().value = ep;
@ -74,4 +75,3 @@ function saveOptions() {
document.addEventListener('DOMContentLoaded', restoreOptions); document.addEventListener('DOMContentLoaded', restoreOptions);
getSaveButton().addEventListener('click', saveOptions);

View file

@ -1,14 +1,13 @@
{ {
"icons": { "name": "<webpack managed>",
"128": "unicorn.png" "version": "<webpack managed>",
"background": {
"scripts": ["background.js"],
"persistent": false
}, },
"options_ui": { "options_ui": {
"page": "options.html" "page": "options.html"
}, },
"background": {
"page": "background.html"
},
"browser_action": { "browser_action": {
"default_icon": "unicorn.png", "default_icon": "unicorn.png",
"default_popup": "popup.html", "default_popup": "popup.html",
@ -22,5 +21,8 @@
"description": "Capture page, with extra information" "description": "Capture page, with extra information"
} }
}, },
"icons": {
"128": "unicorn.png"
},
"manifest_version": 2 "manifest_version": 2
} }

View file

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title></title> <script type="text/javascript" src="options_page.js"/></script>
<style> <style>
input:invalid { input:invalid {
background-color: red; background-color: red;

View file

@ -2,6 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<script type="text/javascript" src="popup.js"></script>
</head> </head>
<body> <body>
<!-- TODO ugh didn't work --> <!-- TODO ugh didn't work -->

View file

@ -2,8 +2,7 @@ const webpack = require('webpack'),
path = require('path'), path = require('path'),
CleanWebpackPlugin = require('clean-webpack-plugin'), CleanWebpackPlugin = require('clean-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin'), CopyWebpackPlugin = require('copy-webpack-plugin'),
WebpackExtensionManifestPlugin = require('webpack-extension-manifest-plugin'), WebpackExtensionManifestPlugin = require('webpack-extension-manifest-plugin');
HtmlWebpackPlugin = require('html-webpack-plugin');
// TODO remove plugins from package.json // TODO remove plugins from package.json
const T = { const T = {
@ -79,26 +78,23 @@ if (target === T.FIREFOX) {
manifestExtra.browser_action = {browser_style: true}; manifestExtra.browser_action = {browser_style: true};
} }
var fileExtensions = ["jpg", "jpeg", "png", "gif", "eot", "otf", "svg", "ttf", "woff", "woff2"];
const build_path = path.join(__dirname, "dist"); // TODO target?? const build_path = path.join(__dirname, "dist"); // TODO target??
var options = { const options = {
mode: 'production', // TODO eh?? mode: dev ? 'development' : 'production', // TODO map directly from MODE env var?
optimization: { optimization: {
// https://webpack.js.org/configuration/optimization // https://webpack.js.org/configuration/optimization
// don't think minimize worth it for such a tiny extension // don't think minimize worth it for such a tiny extension
minimize: false minimize: false
}, },
entry: { entry: {
popup : path.join(__dirname, "src", "js", "popup.js"), background : path.join(__dirname, "src", "js", "background"),
options : path.join(__dirname, "src", "js", "options_page.js"), popup : path.join(__dirname, "src", "js", "popup"),
background: path.join(__dirname, "src", "js", "background.js") options_page: path.join(__dirname, "src", "js", "options_page"),
}, },
output: { output: {
path: build_path, path: build_path,
// TODO why bundle??? filename: "[name].js",
filename: "[name].bundle.js",
}, },
module: { module: {
rules: [ rules: [
@ -111,12 +107,7 @@ var options = {
}, },
{ {
test: /\.css$/, test: /\.css$/,
loader: "style-loader!css-loader", loader: "style-loader!css-loader", // TODO different from promnesia??
exclude: /node_modules/
},
{
test: new RegExp('\.(' + fileExtensions.join('|') + ')$'),
loader: "file-loader?name=[name].[ext]",
exclude: /node_modules/ exclude: /node_modules/
}, },
{ {
@ -130,32 +121,14 @@ var options = {
new CleanWebpackPlugin([build_path + "/*"]), new CleanWebpackPlugin([build_path + "/*"]),
new CopyWebpackPlugin([ new CopyWebpackPlugin([
{ from: 'src/img/*.png', flatten: true }, { from: 'src/img/*.png', flatten: true },
{ from: 'src/*.html' , flatten: true },
]), ]),
// expose and write the allowed env vars on the compiled bundle
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(env.NODE_ENV)
}),
new WebpackExtensionManifestPlugin({ new WebpackExtensionManifestPlugin({
config: { config: {
base: baseManifest, base: baseManifest,
extend: manifestExtra, extend: manifestExtra,
} }
}), }),
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "popup.html"),
filename: "popup.html",
chunks: ["popup"],
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "options.html"),
filename: "options.html",
chunks: ["options"]
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "background.html"),
filename: "background.html",
chunks: ["background"]
}),
] ]
}; };