This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
99 lines (91 loc) · 2.31 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
const webpack = require("webpack");
const path = require("path");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const cacheGroups = {
vendor: {
chunks: "initial",
test: /node_modules/,
name: "vendor",
enforce: true
}
};
const main = {
output: {
pathinfo: false,
path: path.resolve(__dirname, "./dist"),
filename: "[name].js",
publicPath: "/",
},
stats: { children: false, timings: true, colors: true },
devtool: "eval-source-map",
entry: {
app: "./src/index.tsx",
},
devServer: {
disableHostCheck: true,
historyApiFallback: {
rewrites: [{ from: /.*\.html/, to: "/" }]
},
stats: { children: false },
https: false,
host: "localhost",
port: "8080",
contentBase: path.join(__dirname, 'dist'),
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".png"],
modules: [path.resolve("./src"), path.resolve("./node_modules")],
plugins: [new TsconfigPathsPlugin()]
},
module: {
rules: [
{
test: /\.ts(x?)$/,
include: [path.resolve("./src")],
exclude: [/node_modules/, /test\.tsx?$/, path.resolve("./modules")],
use: [
{
loader: "awesome-typescript-loader",
options: { useCache: true, forceIsolatedModules: true }
}
]
},
{
test: /\.(png|jpg|gif)$/i,
include: [path.resolve(__dirname,"./src/assets")],
use: [
{
loader: 'url-loader',
}
]
}
]
},
plugins: [
new webpack.NamedModulesPlugin(),
new HtmlWebpackPlugin({
template: "./index.html",
chunks: ["app", ...Object.values(cacheGroups).map(x => x.name)],
chunksSortMode: "none"
}),
// new CleanWebpackPlugin({ cleanStaleWebpackAssets: false }),
new webpack.WatchIgnorePlugin([/css\.d\.ts$/, /test\.ts(x?)/])
],
//TODO: Make sure have separate dependencies for module
optimization: {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: {
chunks: "async",
cacheGroups: {
vendor: { test: /node_modules/ }
}
}
},
// externals: {
// react: 'React'
// }
};
module.exports = main;