forked from bilibili/flv.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
70 lines (62 loc) · 1.49 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
const webpack = require('webpack');
const pkg = require('./package.json');
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
let config = {
entry: './src/index.js',
output: {
filename: 'flv.js',
path: path.resolve(__dirname, 'dist'),
library: 'flvjs',
libraryTarget: 'umd',
environment: {
arrowFunction: false,
bigIntLiteral: false,
const: false,
destructuring: false,
dynamicImport: false,
forOf: false,
module: false
}
},
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
fallback: {
fs: false,
path: false
}
},
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version)
})
],
optimization: {
minimizer: [
new TerserPlugin({
extractComments: false,
})
]
},
module: {
rules: [
{
test: /\.(ts|js)$/,
use: 'ts-loader',
exclude: /node-modules/
},
{
enforce: 'pre',
test: /\.js$/,
use: 'source-map-loader'
}
]
}
};
module.exports = (env, argv) => {
if (argv.mode === 'production') {
config.output.filename = 'flv.min.js';
}
return config;
};