-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathwebpack.config.js
131 lines (129 loc) · 3.88 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
const webpack = require('webpack');
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const packageData = require('./package.json');
const chalk = require('chalk');
const TerserPlugin = require('terser-webpack-plugin');
const {insertStylesWithNonce} = require('@playkit-js/webpack-common');
module.exports = (env, { mode }) => {
const { playerType } = env;
const playerFileType = playerType === 'ovp' ? 'ovp' : 'tv';
console.log(
chalk.blue.bold('Player Type:') +
' ' +
chalk.green.bold(playerType) +
' | ' +
chalk.red.bold('Player Version:') +
' ' +
chalk.redBright.bold(packageData.version) +
' | ' +
chalk.yellow.bold('Mode:') +
' ' +
chalk.yellow.bold(mode) +
'\n'
);
return {
target: 'web',
entry: './src/index.ts',
devtool: 'source-map',
optimization: {
minimizer: [new TerserPlugin({terserOptions: {mangle: {reserved: ['module']}}})],
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader']
},
{
test: /\.(ts|js)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
bugfixes: true // This option will be enabled by default in Babel 8.
// run 'npx browserslist' to see supported browsers and version by the current target config & 'npx babel --show-config' to see the babel final target config
}
],
'@babel/preset-typescript'
]
}
}
},
{
test: /\.css$/i,
use: [
{
loader: "style-loader",
options: {
attributes: {
id: `${packageData.name}`
},
insert: insertStylesWithNonce
}
},
{
loader: "css-loader",
},
]
}
]
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
'@playkit-js/playkit-js-providers/ovp-provider': path.resolve(`./node_modules/@playkit-js/playkit-js-providers/dist/playkit-${playerType}-provider`),
'player-defaults': path.resolve(`./src/${playerType}/player-defaults`),
poster: path.resolve(`./src/${playerType}/poster`),
'plugins-config-store': path.resolve(`./src/${playerType}/plugins/plugins-config-store`),
'hls.js': path.resolve(__dirname, 'node_modules/hls.js/dist/hls.min.js')
}
},
output: {
filename: `kaltura-${playerFileType}-player.js`,
path: path.resolve(__dirname, 'dist'),
library: {
name: 'KalturaPlayer',
type: 'umd'
},
clean: mode === 'development'
},
devServer: {
static: {
directory: path.join(__dirname, 'demo')
},
client: {
progress: true
}
},
plugins: [
new webpack.DefinePlugin({
__PLAYER_TYPE__: JSON.stringify(playerType),
__VERSION__: JSON.stringify(packageData.version),
__NAME__: JSON.stringify(packageData.name),
__PACKAGE_URL__: JSON.stringify(packageData.repository.url),
__CONFIG_DOCS_URL__: JSON.stringify(`${packageData.repository.url}/blob/master/docs/configuration.md`)
}),
new CopyPlugin({
patterns: [
{
from: 'node_modules/@playkit-js/playkit-js-ui/translations',
to: 'translations',
globOptions: {
ignore: ['en.i18n.json']
},
transform: function (content) {
return JSON.stringify(JSON.parse(content));
}
}
]
})
],
ignoreWarnings: [/Failed to parse source map/]
};
};