-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
86 lines (84 loc) · 2.14 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
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const isDev = () => process.env.NODE_ENV !== "production";
module.exports = {
entry: ["react-hot-loader/patch", "./src/index.tsx"],
output: {
path: path.resolve(__dirname, "dist"),
filename: "static/js/[name].[hash].js",
chunkFilename: "static/chunks/[name].[hash].js"
// publicPath: "/"
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
alias: {
"react-dom": "@hot-loader/react-dom",
"@": path.resolve(__dirname, "src")
}
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: ["babel-loader", "awesome-typescript-loader"]
},
{
test: /\.s?css$/,
use: [
isDev() ? "style-loader" : MiniCssExtractPlugin.loader,
"css-loader",
"postcss-loader",
"sass-loader"
]
},
{
test: /\.svg$/,
loader: "svg-sprite-loader"
},
{
test: /\.(jpg|png|bmp|jpe?g|gif|ico)$/,
loader: "url-loader",
options: {
limit: 8192,
outputPath: "./static/assets/images",
name: "[name].[hash].[ext]"
// publicPath: "./static/assets/images"
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)$/,
loader: "url-loader",
options: {
limit: 8192,
outputPath: "./static/assets/media",
name: "[name].[hash].[ext]"
// publicPath: "./static/assets/media"
}
},
{
test: /\.(woff2?|eot|ttf|otf)$/,
loader: "url-loader",
options: {
limit: 8192,
outputPath: "./static/assets/fonts",
name: "[name].[hash].[ext]"
// publicPath: "./static/assets/fonts"
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
title: "web-im",
template: "./src/index.html",
favicon: "./src/favicon.ico"
})
]
};