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)
yield driver
finally:
# confirm('ready to continue?')
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() {
getSaveButton().addEventListener('click', saveOptions);
get_options(opts => {
const ep = opts.endpoint;
getEndpoint().value = ep;
@ -74,4 +75,3 @@ function saveOptions() {
document.addEventListener('DOMContentLoaded', restoreOptions);
getSaveButton().addEventListener('click', saveOptions);

View file

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

View file

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

View file

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

View file

@ -2,8 +2,7 @@ const webpack = require('webpack'),
path = require('path'),
CleanWebpackPlugin = require('clean-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin'),
WebpackExtensionManifestPlugin = require('webpack-extension-manifest-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin');
WebpackExtensionManifestPlugin = require('webpack-extension-manifest-plugin');
// TODO remove plugins from package.json
const T = {
@ -79,26 +78,23 @@ if (target === T.FIREFOX) {
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??
var options = {
mode: 'production', // TODO eh??
const options = {
mode: dev ? 'development' : 'production', // TODO map directly from MODE env var?
optimization: {
// https://webpack.js.org/configuration/optimization
// don't think minimize worth it for such a tiny extension
minimize: false
},
entry: {
popup : path.join(__dirname, "src", "js", "popup.js"),
options : path.join(__dirname, "src", "js", "options_page.js"),
background: path.join(__dirname, "src", "js", "background.js")
background : path.join(__dirname, "src", "js", "background"),
popup : path.join(__dirname, "src", "js", "popup"),
options_page: path.join(__dirname, "src", "js", "options_page"),
},
output: {
path: build_path,
// TODO why bundle???
filename: "[name].bundle.js",
filename: "[name].js",
},
module: {
rules: [
@ -111,12 +107,7 @@ var options = {
},
{
test: /\.css$/,
loader: "style-loader!css-loader",
exclude: /node_modules/
},
{
test: new RegExp('\.(' + fileExtensions.join('|') + ')$'),
loader: "file-loader?name=[name].[ext]",
loader: "style-loader!css-loader", // TODO different from promnesia??
exclude: /node_modules/
},
{
@ -130,32 +121,14 @@ var options = {
new CleanWebpackPlugin([build_path + "/*"]),
new CopyWebpackPlugin([
{ 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({
config: {
base: baseManifest,
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"]
}),
]
};