-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.common.js
48 lines (43 loc) · 1.03 KB
/
webpack.common.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
const webpack = require('webpack'),
merge = require('webpack-merge'),
path = require('path'),
CleanWebpackPlugin = require('clean-webpack-plugin');
const libraryName = 'webstompobs',
dist = '/dist';
const common = {
target: 'web',
entry: __dirname + '/src/index.ts',
context: path.resolve("./src"),
output: {
path: path.join(__dirname, dist),
filename: libraryName + '.bundle.js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
resolve: {
extensions: ['.js', '.ts', '.jsx', '.tsx' ]
},
plugins: [
new CleanWebpackPlugin(['dist'])
],
module: {
rules: [
{ test: /\.tsx?$/, loader: "ts-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
}
};
const clientConfig = merge(common, {
target: 'web',
output: {
filename: libraryName + '.web.js'
}
});
const serverConfig = merge(common, {
target: 'node',
output: {
filename: libraryName + '.node.js'
}
});
module.exports = [ serverConfig, clientConfig ];