forked from aws-samples/amazon-sumerian-hosts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
101 lines (95 loc) · 2.32 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
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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const corePath = path.resolve(__dirname, './src/core/');
const threePath = path.resolve(__dirname, 'src/three.js/');
const babylonPath = path.resolve(__dirname, 'src/Babylon.js/');
const baseConfig = {
mode: 'production',
devtool: 'eval-source-map',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
library: 'HOST',
libraryTarget: 'umd',
libraryExport: 'default',
umdNamedDefine: true,
globalObject: '(typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this)'
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
sourceMap: true,
parallel: true,
}),
],
},
module: {
rules: [
{
test: /\.(ico)$/,
exclude: /(node_modules|bower_components)/,
loader: 'file-loader?name=[name].[ext]',
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/,
query: {
presets: ['@babel/preset-env'],
},
},
],
},
plugins: [
new webpack.BannerPlugin({
banner: `Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0`,
entryOnly: true
}),
],
resolve: {
alias: {
core: corePath,
},
},
};
const coreConfig = {
...baseConfig,
entry: {
'host.core': ['babel-polyfill', './src/core/index.js'],
},
resolve: {
alias: {
...baseConfig.resolve.alias,
app: corePath,
},
},
};
const threeConfig = {
...baseConfig,
entry: {
'host.three': ['babel-polyfill', './src/three.js/index.js'],
},
resolve: {
alias: {
...baseConfig.resolve.alias,
app: threePath,
},
},
};
const babylonConfig = {
...baseConfig,
entry: {
'host.babylon': ['babel-polyfill', './src/Babylon.js/index.js'],
},
resolve: {
alias: {
...baseConfig.resolve.alias,
app: babylonPath,
},
},
};
module.exports = [coreConfig, threeConfig, babylonConfig];