-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
98 lines (90 loc) · 2.26 KB
/
webpack.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const fs = require( 'fs' );
const webpack = require( 'webpack' );
const plugins = [];
const env = process.env.WEBPACK_ENV;
if ( env === 'build' ) {
plugins.push( new webpack.optimize.UglifyJsPlugin( { minimize: true } ) );
}
const libraryName = 'error-trapper';
const libraryConfig = {
plugins,
entry: `${__dirname}/src/error-trapper.js`,
devtool: 'source-map',
output: {
path: __dirname,
filename: 'index.js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
loaders: [
{
test: /(\.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
}
]
},
resolve: {
extensions: [ '.js' ]
}
};
const esprimaPrebuildConfig = {
plugins,
entry: `${__dirname}/src/prebuilds/esprima.js`,
devtool: 'source-map',
output: {
path: __dirname + '/lib',
filename: 'esprima-bundle.js',
library: 'esprima-bundle',
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
loaders: [
{
test: /(\.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
}
]
},
resolve: {
extensions: [ '.js' ]
}
};
function buildTestName( testName ) {
return {
plugins,
entry: {
[ testName ]: `${__dirname}/test/${testName}/main.js`
},
devtool: 'source-map',
output: {
path: `${__dirname}/test/${testName}/assets`,
filename: 'bundle.js',
umdNamedDefine: true
},
module: {
loaders: [
{
test: /(\.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
}
]
},
resolve: {
extensions: [ '.js' ]
}
}
}
var exports = [ libraryConfig, esprimaPrebuildConfig ];
if ( env !== 'build' ) {
const files = fs.readdirSync( './test' );
files.forEach( ( testDirectory ) => {
exports.push( buildTestName( testDirectory ) )
} );
}
module.exports = exports;