-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
104 lines (103 loc) · 3.17 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
var ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const webpack = require("webpack");
const path = require("path");
module.exports = {
devServer: {
host: "0.0.0.0",
port: 16000,
hot: true,
contentBase: path.resolve(__dirname, "src"),
publicPath: "/"
},
plugins: [
new webpack.WatchIgnorePlugin([
/css\.d\.ts$/
]),
new CleanWebpackPlugin(["dist"]),
new HtmlWebpackPlugin({
template: "./src/index.html"
}),
new webpack.HotModuleReplacementPlugin()
],
devtool: "inline-source-map",
entry: ["webpack/hot/only-dev-server", "./src/index.tsx"],
output: {
filename: "[name].js",
chunkFilename: "[name].js",
path: path.join(__dirname, "/build")
},
optimization: {
splitChunks: {
chunks: "all",
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10
},
src: {
test: /[\\/]src[\\/]/,
name(module) {
const src = module.context
.split("/")
.join(".")
.substr(1);
return `${src}`;
}
}
}
}
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/
},
{
test: /\.(scss|css)$/,
use: [
"style-loader?sourceMap", // creates style nodes from JS strings
"css-loader?sourceMap", // translates CSS into CommonJS
"sass-loader?sourceMap"
],
exclude: /\.module\.scss$/
}, {
test: /\.(scss)$/,
use: [
"style-loader?sourceMap",
{
loader: "typings-for-css-modules-loader",
options: {
sourceMap: true,
namedExport: true,
localIdentName: '[local]----[hash:base64:5]',
modules: true
}
},
"sass-loader?sourceMap"
],
include: /\.module\.scss$/
},
{
test: /\.(woff(2)?|ttf|eot|svg|png)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: "file-loader"
}
]
}
]
},
resolve: {
alias: {
'react-dom': '@hot-loader/react-dom',
},
modules: [path.resolve(__dirname, "./src"), "node_modules"],
extensions: [".ts", ".tsx", ".js", ".json"]
}
};