wallet-core/webpack.config.js
Florian Dold d381226f21
Simplify loading of the emscripten lib.
This removes an ugly hack and makes it possible to access the emscripten
compiled library from within nodejs test cases more easily.
2017-05-27 18:43:34 +02:00

77 lines
2.0 KiB
JavaScript

const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
module.exports = function (env) {
env = env || {};
const base = {
output: {
filename: '[name]-bundle.js',
chunkFilename: "[id].chunk.js",
path: path.resolve(__dirname, "dist"),
},
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",
}
if (env.prod) {
base.plugins.push(new webpack.optimize.UglifyJsPlugin());
base.plugins.push(new webpack.LoaderOptionsPlugin({minimize: true}));
}
const configWebWorker = {
entry: {"cryptoWorker": "./src/crypto/cryptoWorker.ts"},
target: "webworker",
};
const configBackground = {
entry: {"background": "./src/background/background.ts"},
};
const configContentScript = {
entry: {"contentScript": "./src/content_scripts/notify.ts"},
};
const configExtensionPages = {
entry: {
"add-auditor": "./src/pages/add-auditor.tsx",
"auditors": "./src/pages/auditors.tsx",
"confirm-contract": "./src/pages/confirm-contract.tsx",
"confirm-create-reserve": "./src/pages/confirm-create-reserve.tsx",
"error": "./src/pages/error.tsx",
"logs": "./src/pages/logs.tsx",
"popup": "./src/pages/popup.tsx",
"show-db": "./src/pages/show-db.ts",
"tree": "./src/pages/tree.tsx",
"payback": "./src/pages/payback.tsx",
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: "page-common",
minChunks: 2,
}),
],
};
return [
merge(base, configBackground),
merge(base, configWebWorker),
merge(base, configExtensionPages),
merge(base, configContentScript)
];
}