forked from davidben/webathena
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack-test.config.js
66 lines (61 loc) · 1.97 KB
/
webpack-test.config.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const WebpackShellPluginNext = require('webpack-shell-plugin-next');
const path = require('path');
const webpack = require('webpack');
module.exports = (env) => {
var config = {
target: 'node',
mode: 'production',
entry: {
test: {
import: './test/webpack-entry.js',
},
},
plugins: [
new webpack.ProvidePlugin({
// node-installed things
assert: ['chai', 'assert'],
// things in ./src/contrib
sjcl: path.resolve(path.join(__dirname, 'src/contrib/sjcl.js')),
// Our modules
log: [path.resolve(path.join(__dirname, 'src/js/util.js')), 'log'],
arrayutils: [path.resolve(path.join(__dirname, 'src/js/arrayutils.js')), 'default'],
asn1: [path.resolve(path.join(__dirname, 'src/js/asn1.js')), 'default'],
kcrypto: [path.resolve(path.join(__dirname, 'src/js/kcrypto.js')), 'default'],
krb: [path.resolve(path.join(__dirname, 'src/js/krb.js')), 'default'],
// Our test utilities
arrayToHex: [path.resolve(path.join(__dirname, 'test/lib/test-utils.js')), 'arrayToHex'],
arraysEqual: [path.resolve(path.join(__dirname, 'test/lib/test-utils.js')), 'arraysEqual'],
}),
new WebpackShellPluginNext({
onAfterDone: {
scripts: ["npx mocha test/dist/test.js"],
},
swallowError: env['WEBPACK_WATCH'],
}),
],
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'test/dist'),
clean: true,
},
resolve: {
fallback: {
"crypto": false,
},
},
watchOptions: {
ignored: [
// emacs temp/lock files
'**/*~',
'**/.#*',
// vim swap files
'**/.*.swp',
],
},
};
return config;
};