-
Notifications
You must be signed in to change notification settings - Fork 101
/
webpack.config.js
158 lines (151 loc) · 3.02 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
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
149
150
151
152
153
154
155
156
157
158
var webpack = require('webpack');
var path = require("path");
const TerserPlugin = require('terser-webpack-plugin');
const BUILD_DIR = 'build';
function publicPath() {
return '';
}
var plugins = [
new webpack.DefinePlugin({
'__OGV_FULL_VERSION__': JSON.stringify(process.env.OGV_FULL_VERSION)
}),
];
var babelRuleES6 = {
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: {
"chrome": 84,
"edge": 16,
"safari": 11.1,
"firefox": 78,
"opera": 103,
}
}
]
],
plugins: [
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-transform-runtime'
]
}
}
};
var urlLoader = {
test: /\.(png|gif|jpg|jpeg|mp3|mp4|webm|ogg)$/,
exclude: /node_modules/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
},
],
};
var optopts = {
minimizer: [
new TerserPlugin({
terserOptions: {
keep_fnames: true
}
})
]
};
module.exports = [
{
// Main entry point! - ES6
entry: './src/js/ogv.js',
mode: 'production',
output: {
path: path.resolve(__dirname, BUILD_DIR),
publicPath: publicPath(),
filename: 'ogv.js',
libraryTarget: 'umd',
library: 'ogvjs'
},
plugins: plugins,
module: {
rules: [
babelRuleES6,
urlLoader
]
},
optimization: optopts,
},
{
// Alt limited entry point for compat testing before loading
entry: './src/js/ogv-support.js',
mode: 'production',
output: {
path: path.resolve(__dirname, BUILD_DIR),
publicPath: publicPath(),
filename: 'ogv-support.js'
},
plugins: plugins,
module: {
rules: [
babelRuleES6,
urlLoader
]
}
},
{
// Alt limited entry point for just exposting the version marker string
entry: './src/js/ogv-version.js',
mode: 'production',
output: {
path: path.resolve(__dirname, BUILD_DIR),
publicPath: publicPath(),
filename: 'ogv-version.js'
},
plugins: plugins,
module: {
rules: [
babelRuleES6,
urlLoader
]
},
optimization: optopts,
},
{
entry: './src/js/workers/ogv-worker-audio.js',
mode: 'production',
output: {
path: path.resolve(__dirname, BUILD_DIR),
publicPath: publicPath(),
filename: 'ogv-worker-audio.js'
},
plugins: plugins,
module: {
rules: [
babelRuleES6,
urlLoader
]
},
optimization: optopts,
},
{
entry: './src/js/workers/ogv-worker-video.js',
mode: 'production',
output: {
path: path.resolve(__dirname, BUILD_DIR),
publicPath: publicPath(),
filename: 'ogv-worker-video.js'
},
plugins: plugins,
module: {
rules: [
babelRuleES6,
urlLoader
]
},
optimization: optopts,
},
];