forked from triniwiz/horizon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.test.config.js
77 lines (74 loc) · 2.08 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
67
68
69
70
71
72
73
74
75
76
77
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const DEV_BUILD = (process.env.NODE_ENV !== 'production')
const SOURCEMAPS = !process.env.NO_SOURCEMAPS
module.exports = {
entry: {
test: './test/test.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
pathinfo: DEV_BUILD, // Add module filenames as comments in the bundle
devtoolModuleFilenameTemplate: function(file) {
if (file.resourcePath.indexOf('webpack') >= 0) {
return `webpack:///${file.resourcePath}`
} else {
// Show correct paths in stack traces
return path.join('..', file.resourcePath).replace(/~/g, 'node_modules')
}
},
},
target: 'web',
debug: DEV_BUILD,
devtool: SOURCEMAPS ? 'source-map' : false,
externals: {
// These modules are not packaged into test.js. Webpack allows
// them to be required natively at runtime when the tests are run
// in node
'./horizon.js': 'commonjs ./horizon.js',
ws: 'commonjs ws',
'source-map-support': 'commonjs source-map-support',
},
module: {
noParse: [
// Pre-built files don't need parsing
/mocha\/mocha\.js/,
/chai\/chai\.js/,
/lodash\/lodash\.js/,
/source-map-support/,
/rxjs\/bundles\/Rx\.umd\.js/,
],
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
cacheDirectory: true,
presets: [
'babel-preset-es2015-loose',
{ plugins: [
[ 'babel-plugin-transform-runtime', { polyfill: false } ],
'babel-plugin-transform-function-bind',
'babel-plugin-transform-async-to-generator', // for async await
] },
],
},
},
],
},
node: {
// Don't include unneeded node libs in package
process: false,
fs: false,
__dirname: false,
__filename: false,
},
plugins: [
new CopyWebpackPlugin([
{ from: './test/test.html' },
{ from: './node_modules/mocha/mocha.css' },
]),
],
}