-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.test.js
148 lines (137 loc) · 4.18 KB
/
webpack.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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const path = require('path');
const _root = path.resolve(__dirname, '.');
/**
* Helpers
*/
const helpers = {
root: function (args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [_root].concat(args));
}
};
/**
* TypeScript Compiler Transformer for TypeScript Object Mapper
* (it and test it)
*/
const TSObjectMapperTransformer = require("./dist/transformer");
/**
* Webpack configuration
*
* See: http://webpack.github.io/docs/configuration.html#cli
*/
module.exports = (options) => {
return {
/**
* These options change how modules are resolved.
*
* See: https://webpack.js.org/configuration/resolve/
*/
resolve: {
/**
* Automatically resolve certain extensions.
*
* See: https://webpack.js.org/configuration/resolve/#resolve-extensions
*/
extensions: ['.ts']
},
/**
* Instructs webpack to target a specific environment.
*
* See: https://webpack.js.org/concepts/targets/
*/
target: 'web',
/*
* The entry point for the bundle
*
* See: https://webpack.js.org/configuration/entry-context/#entry
*/
entry: {
'test': helpers.root('src/test', 'main.spec.ts')
},
/**
* Options affecting the output of the compilation.
*
* See: https://webpack.js.org/concepts/output/
* See: https://webpack.js.org/configuration/output/
*/
output: {
/**
* The output directory as an absolute path.
*
* See: https://webpack.js.org/configuration/output/#output-path
*/
path: helpers.root('dist/test'),
/**
* Specifies the name of each output file on disk.
* IMPORTANT: You must not specify an absolute path here!
*
* See: http://webpack.github.io/docs/configuration.html#output-filename
*/
filename: '[name].spec.js'
},
/**
* Configuration regarding modules.
*
* See: https://webpack.js.org/configuration/module/
*/
module: {
/**
* Rules for modules (configure loaders, parser options, etc.)
*
* See: https://webpack.js.org/configuration/module/#module-rules
*/
rules: [
/**
* TypeScript loader for webpack
*
* See: https://github.com/TypeStrong/ts-loader
*/
{
test: /\.ts$/,
loader: 'ts-loader',
options: {
configFile: helpers.root('tsconfig.json'),
context: helpers.root('src/test'),
getCustomTransformers: () => {
return {
before: [
TSObjectMapperTransformer
]
};
}
}
}
]
},
/**
* Add additional plugins to the compiler.
*
* See: http://webpack.github.io/docs/configuration.html#plugins
*/
plugins: [],
/**
* Developer tool to enhance debugging
*
* See: http://webpack.github.io/docs/configuration.html#devtool
* See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
*/
devtool: 'source-map',
/**
* Include polyfills or mocks for various node stuff
* Description: Node configuration
*
* See: https://webpack.js.org/configuration/node/
*/
"node": {
"fs": "empty",
"global": true,
"crypto": "empty",
"tls": "empty",
"net": "empty",
"process": true,
"module": false,
"clearImmediate": false,
"setImmediate": false
}
}
};