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-04-20 03:09:25 +02:00
|
|
|
|
|
|
|
|
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?$/,
|
|
|
|
loader: 'ts-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
exclude: /taler-emscripten-lib/,
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: [path.resolve(__dirname, "./"), "node_modules"],
|
|
|
|
extensions: [".tsx", ".ts", ".js"]
|
|
|
|
},
|
|
|
|
plugins: [],
|
|
|
|
devtool: "source-map",
|
2017-05-29 02:44:28 +02:00
|
|
|
externals: ["fs", "path", "child_process", /.*taler-emscripten-lib.*/],
|
2017-04-24 23:18:15 +02:00
|
|
|
}
|
|
|
|
if (env.prod) {
|
|
|
|
base.plugins.push(new webpack.optimize.UglifyJsPlugin());
|
|
|
|
base.plugins.push(new webpack.LoaderOptionsPlugin({minimize: true}));
|
|
|
|
}
|
|
|
|
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",
|
|
|
|
"popup": "./src/webex/pages/popup.tsx",
|
|
|
|
"show-db": "./src/webex/pages/show-db.ts",
|
|
|
|
"tree": "./src/webex/pages/tree.tsx",
|
|
|
|
"payback": "./src/webex/pages/payback.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)
|
|
|
|
];
|
|
|
|
}
|