2017-04-20 03:09:25 +02:00
|
|
|
const path = require('path');
|
|
|
|
const webpack = require('webpack');
|
2017-04-24 23:18:15 +02:00
|
|
|
const merge = require('webpack-merge');
|
2017-08-14 04:59:43 +02:00
|
|
|
const { CheckerPlugin } = require('awesome-typescript-loader')
|
2019-05-08 01:32:33 +02:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2017-04-20 03:09:25 +02:00
|
|
|
|
|
|
|
|
2017-05-30 14:38:29 +02:00
|
|
|
function externalsCb(context, request, callback) {
|
|
|
|
if (/.*taler-emscripten-lib.*/.test(request)) {
|
|
|
|
callback(null, "undefined");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
|
2017-04-24 23:18:15 +02:00
|
|
|
module.exports = function (env) {
|
2017-04-26 01:30:52 +02:00
|
|
|
env = env || {};
|
2017-04-24 23:18:15 +02:00
|
|
|
const base = {
|
|
|
|
output: {
|
|
|
|
filename: '[name]-bundle.js',
|
2019-05-08 04:53:26 +02:00
|
|
|
chunkFilename: "[name]-bundle.js",
|
2017-05-23 14:29:34 +02:00
|
|
|
path: path.resolve(__dirname, "dist"),
|
2017-04-24 23:18:15 +02:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
noParse: /taler-emscripten-lib/,
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
2017-08-14 04:59:43 +02:00
|
|
|
loader: 'awesome-typescript-loader',
|
2019-08-16 15:03:52 +02:00
|
|
|
exclude: /node_modules|taler-emscripten-lib|nodeEmscriptenLoader|synchronousWorker/,
|
2017-04-24 23:18:15 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: [path.resolve(__dirname, "./"), "node_modules"],
|
|
|
|
extensions: [".tsx", ".ts", ".js"]
|
|
|
|
},
|
2017-08-14 04:59:43 +02:00
|
|
|
plugins: [
|
|
|
|
new CheckerPlugin(),
|
|
|
|
],
|
2017-04-24 23:18:15 +02:00
|
|
|
devtool: "source-map",
|
2017-05-30 14:38:29 +02:00
|
|
|
externals: [
|
|
|
|
externalsCb,
|
|
|
|
"child_process",
|
|
|
|
],
|
2019-05-08 01:32:33 +02:00
|
|
|
optimization: {
|
|
|
|
minimize: false,
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
sourceMap: true,
|
|
|
|
terserOptions: {
|
|
|
|
keep_classnames: true,
|
|
|
|
keep_fnames: true,
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
}
|
2017-04-24 23:18:15 +02:00
|
|
|
}
|
|
|
|
const configWebWorker = {
|
2019-08-16 15:03:52 +02:00
|
|
|
entry: {"cryptoWorker": "./src/crypto/browserWorkerEntry.ts"},
|
2017-04-24 23:18:15 +02:00
|
|
|
target: "webworker",
|
2018-09-22 17:18:25 +02:00
|
|
|
name: "webworker",
|
2017-04-24 23:18:15 +02:00
|
|
|
};
|
2017-04-20 03:09:25 +02:00
|
|
|
|
2017-04-24 23:18:15 +02:00
|
|
|
const configBackground = {
|
2017-05-28 23:15:41 +02:00
|
|
|
entry: {"background": "./src/webex/background.ts"},
|
2018-09-22 17:18:25 +02:00
|
|
|
name: "background",
|
2017-04-24 23:18:15 +02:00
|
|
|
};
|
2017-04-20 03:09:25 +02:00
|
|
|
|
2017-04-24 23:18:15 +02:00
|
|
|
const configContentScript = {
|
2017-05-28 23:15:41 +02:00
|
|
|
entry: {"contentScript": "./src/webex/notify.ts"},
|
2018-09-22 17:18:25 +02:00
|
|
|
name: "contentScript",
|
2017-04-24 23:18:15 +02:00
|
|
|
};
|
2017-04-20 03:09:25 +02:00
|
|
|
|
2017-04-24 23:18:15 +02:00
|
|
|
const configExtensionPages = {
|
|
|
|
entry: {
|
2017-05-28 23:15:41 +02:00
|
|
|
"add-auditor": "./src/webex/pages/add-auditor.tsx",
|
|
|
|
"auditors": "./src/webex/pages/auditors.tsx",
|
2018-09-20 02:56:13 +02:00
|
|
|
"benchmark": "./src/webex/pages/benchmark.tsx",
|
2017-05-28 23:15:41 +02:00
|
|
|
"confirm-contract": "./src/webex/pages/confirm-contract.tsx",
|
|
|
|
"confirm-create-reserve": "./src/webex/pages/confirm-create-reserve.tsx",
|
|
|
|
"error": "./src/webex/pages/error.tsx",
|
|
|
|
"logs": "./src/webex/pages/logs.tsx",
|
2017-08-14 04:16:12 +02:00
|
|
|
"payback": "./src/webex/pages/payback.tsx",
|
2017-05-28 23:15:41 +02:00
|
|
|
"popup": "./src/webex/pages/popup.tsx",
|
2017-08-14 04:16:12 +02:00
|
|
|
"reset-required": "./src/webex/pages/reset-required.tsx",
|
|
|
|
"return-coins": "./src/webex/pages/return-coins.tsx",
|
2017-08-27 03:56:19 +02:00
|
|
|
"refund": "./src/webex/pages/refund.tsx",
|
2017-05-28 23:15:41 +02:00
|
|
|
"show-db": "./src/webex/pages/show-db.ts",
|
2017-11-30 04:07:36 +01:00
|
|
|
"tip": "./src/webex/pages/tip.tsx",
|
2017-05-28 23:15:41 +02:00
|
|
|
"tree": "./src/webex/pages/tree.tsx",
|
2017-04-24 23:18:15 +02:00
|
|
|
},
|
2018-09-22 17:18:25 +02:00
|
|
|
name: "pages",
|
2018-09-20 02:56:13 +02:00
|
|
|
optimization: {
|
|
|
|
splitChunks: {
|
2019-05-08 01:32:33 +02:00
|
|
|
cacheGroups: {
|
|
|
|
commons: {
|
|
|
|
name: 'page-common',
|
|
|
|
chunks: 'all',
|
|
|
|
minChunks: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-09-20 02:56:13 +02:00
|
|
|
},
|
2017-04-24 23:18:15 +02:00
|
|
|
};
|
2017-04-20 03:09:25 +02:00
|
|
|
|
2017-04-24 23:18:15 +02:00
|
|
|
return [
|
|
|
|
merge(base, configBackground),
|
|
|
|
merge(base, configWebWorker),
|
|
|
|
merge(base, configExtensionPages),
|
|
|
|
merge(base, configContentScript)
|
|
|
|
];
|
|
|
|
}
|