forked from canalplus/rx-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack-demo.config.js
81 lines (77 loc) · 1.79 KB
/
webpack-demo.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
/* eslint-env node */
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require("webpack");
const RXP_ENV = process.env.RXP_ENV || "production";
const shouldMinify = !!process.env.RXP_MINIFY;
if (["development", "production"].indexOf(RXP_ENV) < 0) {
throw new Error("unknown RXP_ENV " + RXP_ENV);
}
const isDevMode = RXP_ENV === "development";
module.exports = {
mode: isDevMode ? "development" : "production",
entry: path.join(__dirname, "./demo/full/scripts/index.js"),
output: {
path: path.join(__dirname, "./demo/full"),
filename: "bundle.js",
},
optimization: {
minimize: shouldMinify,
minimizer: shouldMinify ? [
new TerserPlugin(),
] : [],
},
performance: {
maxEntrypointSize: shouldMinify ? 1000000 : 2500000,
maxAssetSize: shouldMinify ? 1000000 : 2500000,
},
module: {
rules: [
{
test: /\.jsx?$/,
use: {
loader: "babel-loader",
options: {
cacheDirectory: true,
presets: [
"@babel/react",
["@babel/env", { loose: true, modules: false }],
],
},
},
},
{
test: /\.css$/,
use: [
"style-loader",
"css-loader",
],
},
{
test: /\.(otf|eot|svg|ttf|woff)$/,
use: ["url-loader"],
},
],
},
plugins: [
new webpack.DefinePlugin({
"__DEV__": true,
"__LOGGER_LEVEL__": "\"INFO\"",
"process.env": {
NODE_ENV: JSON.stringify("production"),
},
}),
],
node: {
console: false,
global: true,
process: false,
Buffer: false,
__filename: false,
__dirname: false,
setImmediate: false,
},
watchOptions: {
ignored: /node_modules/,
},
};