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')
|
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',
|
|
|
|
chunkFilename: "[id].chunk.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',
|
2017-04-24 23:18:15 +02:00
|
|
|
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(),
|
|
|
|
],
|
2017-04-24 23:18:15 +02:00
|
|
|
devtool: "source-map",
|
2017-05-30 14:38:29 +02:00
|
|
|
externals: [
|
|
|
|
externalsCb,
|
|
|
|
"child_process",
|
|
|
|
],
|
2017-04-24 23:18:15 +02:00
|
|
|
}
|
|
|
|
if (env.prod) {
|
2017-06-03 20:48:26 +02:00
|
|
|
//base.plugins.push(new webpack.optimize.UglifyJsPlugin({sourceMap: true}));
|
2017-04-24 23:18:15 +02:00
|
|
|
base.plugins.push(new webpack.LoaderOptionsPlugin({minimize: true}));
|
2017-05-29 15:18:48 +02:00
|
|
|
base.plugins.push(new webpack.DefinePlugin({
|
|
|
|
"process.env.NODE_ENV": JSON.stringify("production")
|
|
|
|
}));
|
2017-04-24 23:18:15 +02:00
|
|
|
}
|
|
|
|
const configWebWorker = {
|
2017-05-27 18:43:11 +02:00
|
|
|
entry: {"cryptoWorker": "./src/crypto/cryptoWorker.ts"},
|
2017-04-24 23:18:15 +02:00
|
|
|
target: "webworker",
|
|
|
|
};
|
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"},
|
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"},
|
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",
|
|
|
|
"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-05-28 23:15:41 +02:00
|
|
|
"show-db": "./src/webex/pages/show-db.ts",
|
|
|
|
"tree": "./src/webex/pages/tree.tsx",
|
2017-04-24 23:18:15 +02:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
|
name: "page-common",
|
|
|
|
minChunks: 2,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
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)
|
|
|
|
];
|
|
|
|
}
|