forked from zxing-js/library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.test.js
41 lines (35 loc) · 1.04 KB
/
webpack.config.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const nodeExternals = require('webpack-node-externals');
const path = require('path');
const ProvidePlugin = require('webpack').ProvidePlugin;
module.exports = (env, argv) => {
const isDebug = env == 'dbg';
const loaders = [];
if (!isDebug) {
loaders.push('istanbul-instrumenter-loader');
}
loaders.push('ts-loader');
return {
mode: 'development',
entry: './src/index.ts',
resolve: {
extensions: ['.ts'],
},
module: {
rules: [{
test: /\.ts$/,
exclude: /node_modules/,
include: path.resolve('src'), // instrument only testing sources with Istanbul, after ts-loader runs
use: loaders
}],
},
plugins: [
new ProvidePlugin({
'TextDecoder': ['text-encoding', 'TextDecoder'],
'TextEncoder': ['text-encoding', 'TextEncoder'],
})
],
target: 'node', // webpack should compile node compatible code
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
devtool: 'inline-cheap-module-source-map'
};
};