-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
executable file
·82 lines (75 loc) · 1.75 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
require("dotenv").config();
const logger = require("console");
const path = require("path");
const webpack = require("webpack");
const STATIC_PATH = "/dist/";
const mode =
process.env.NODE_ENV === "production" ? "production" : "development";
const PWD = process.cwd();
const resolvePath = (relativePath) => path.resolve(PWD, relativePath);
const env = {
process: JSON.stringify({}),
STREAMING_URL: JSON.stringify(
process.env.STREAMING_URL || "http://localhost:90"
),
};
console.info(env);
const config = {
mode,
entry: {
block: "./web/Index.tsx",
},
plugins: [
new webpack.DefinePlugin(env),
],
output: {
publicPath: STATIC_PATH,
path: resolvePath(`.${STATIC_PATH}`),
filename: "[name].js",
chunkFilename: "[name].bundle.js",
libraryTarget: "umd",
},
devtool: "source-map",
optimization: {
minimize: mode === "production",
},
resolve: {
extensions: [".js", ".ts", ".jsx", ".tsx"],
},
module: {
rules: [
{
test: /\.ts(x?)$/,
exclude: [/node_modules/, /third_party/, /server/],
use: {
loader: "ts-loader",
},
},
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" },
{
test: /\.(s?)css$/,
use: ["style-loader", "css-loader"],
//use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.(png|jpe?g|gif|woff|woff2|eot|ttf|svg)$/i,
use: [
{
loader: "file-loader",
},
],
},
],
},
};
if (mode === "development") {
logger.log("Looks like we are in development mode");
config.devServer = {
port: 3000,
hot: true,
static: {
directory: path.join(__dirname, 'web'),
},
}
}
module.exports = config;