-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
108 lines (91 loc) · 2.25 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
/* @mango3d/integratest
*
* /webpack.config.js
*/
/* eslint-disable */ // config file - don't need eslint here
const {join,resolve} = require("path");
const webpack = require("webpack");
const {EnvironmentPlugin} = webpack;
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = () => {
// --- handling env
const target = "dev";
// --- load vars
const pkgVars = require("./package.json");
// --- entries
const entry = "./src/entries/app.tsx";
// --- resolve extensions
const extensions = [".tsx", ".ts", ".js", ".json"];
// --- rules
const rules = [];
rules.push(
// ----- Typescript modules
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{loader: "ts-loader", options: {}},
],
},
);
// --- plugins
const plugins = [];
// ----- Env vars
plugins.push(
new EnvironmentPlugin({
PKG_NAME: pkgVars.name,
VERSION: pkgVars.version,
BUILD_TIME: Date.now(),
}),
);
// ----- HTML handling
plugins.push(
new HtmlWebpackPlugin({
template: "./src/templates/index.html",
inject: true,
xhtml: true,
}),
);
// --- optimization
const optimization = {};
// --- output
const output = {
path: resolve(__dirname, "./dist"),
filename: "js/[name].js",
publicPath: `/`,
};
// --- dev server
const devServer = {
client: {
progress: true,
},
compress: true,
historyApiFallback: true,
hot: true,
open: true,
port: 8000,
static: {
directory: join(__dirname, 'dist'),
},
};
// --- assemble config
const config = {
entry,
mode: "development",
module: {rules},
optimization,
plugins,
resolve: {extensions},
output,
devServer,
devtool: "eval-source-map",
stats: {
all: false,
errors: true,
entrypoints: true,
orphanModules: true,
},
};
// console.log("config:", config);
return config;
};