wallet-core/webpack.config.js

115 lines
2.9 KiB
JavaScript
Raw Normal View History

const path = require('path');
const webpack = require('webpack');
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-05-30 14:38:29 +02:00
function externalsCb(context, request, callback) {
if (/.*taler-emscripten-lib.*/.test(request)) {
callback(null, "undefined");
return;
}
callback();
}
module.exports = function (env) {
env = env || {};
const base = {
output: {
filename: '[name]-bundle.js',
2019-05-08 01:32:33 +02:00
chunkFilename: "[id]-bundle.js",
2017-05-23 14:29:34 +02:00
path: path.resolve(__dirname, "dist"),
},
module: {
noParse: /taler-emscripten-lib/,
rules: [
{
test: /\.tsx?$/,
2017-08-14 04:59:43 +02:00
loader: 'awesome-typescript-loader',
exclude: /node_modules/,
exclude: /taler-emscripten-lib/,
}
]
},
resolve: {
modules: [path.resolve(__dirname, "./"), "node_modules"],
extensions: [".tsx", ".ts", ".js"]
},
2017-08-14 04:59:43 +02:00
plugins: [
new CheckerPlugin(),
],
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,
}
}),
],
}
}
const configWebWorker = {
entry: {"cryptoWorker": "./src/crypto/cryptoWorker.ts"},
target: "webworker",
2018-09-22 17:18:25 +02:00
name: "webworker",
};
const configBackground = {
entry: {"background": "./src/webex/background.ts"},
2018-09-22 17:18:25 +02:00
name: "background",
};
const configContentScript = {
entry: {"contentScript": "./src/webex/notify.ts"},
2018-09-22 17:18:25 +02:00
name: "contentScript",
};
const configExtensionPages = {
entry: {
"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",
"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",
"payback": "./src/webex/pages/payback.tsx",
"popup": "./src/webex/pages/popup.tsx",
"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",
"show-db": "./src/webex/pages/show-db.ts",
2017-11-30 04:07:36 +01:00
"tip": "./src/webex/pages/tip.tsx",
"tree": "./src/webex/pages/tree.tsx",
},
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
},
};
return [
merge(base, configBackground),
merge(base, configWebWorker),
merge(base, configExtensionPages),
merge(base, configContentScript)
];
}