-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
125 lines (122 loc) · 3.26 KB
/
webpack.config.js
File metadata and controls
125 lines (122 loc) · 3.26 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const HtmlWebPackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const getLocalIdent = require('css-loader/lib/getLocalIdent');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require("path");
module.exports = (e, argv) => {
const mode = argv.mode;
const define = argv.define;
let base = {
devServer: {
compress: true,
public: "chat.fanapsoft.ir",
historyApiFallback: true
},
module: {
rules: [
{
test: /\.js$/,
include: [
path.resolve(__dirname, "src"),
path.resolve(__dirname, "node_modules/raduikit/src"),
path.resolve(__dirname, "node_modules/react-icons/*"),
path.resolve(__dirname, "../uikit/src")
],
use: {
loader: "babel-loader"
}
},
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: {minimize: true}
}
]
},
{
test: /\.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
{
loader: "css-loader",
options: {
modules: true,
localIdentName: mode === "production" ? "[hash:base64:5]" : "[local]",
getLocalIdent: (loaderContext, localIdentName, localName, options) => {
return loaderContext.resourcePath.includes('ModalMedia') || loaderContext.resourcePath.includes('emoji') ?
localName :
getLocalIdent(loaderContext, localIdentName, localName, options);
}
}
},
{
loader: "sass-loader",
options: {
data: '@import "../variables.scss";',
includePaths: [__dirname, "styles"]
}
}
]
},
{
test: /\.(png|jpg|gif|ttf|eot|woff2|woff|mp3|svg)$/,
exclude: /oneone\.png/,
use: [
{
loader: "url-loader",
options: {
limit: 2000,
name: "assets/[hash].[ext]"
}
}
]
},
{
test: /oneone\.png/,
use: [
{
loader: "file-loader",
options: {
name: "assets/oneone.[ext]"
}
}
]
}
]
},
plugins: [
new HtmlWebPackPlugin({
template: "./index.html",
filename: "./index.html"
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
//new BundleAnalyzerPlugin()
],
node: {
fs: "empty",
net: "empty",
tls: "empty"
}
};
//IF MODE IS PRODUCTION
if (mode === "production") {
base.output = {
path: __dirname + "/dist",
filename: "index.js",
library: "",
libraryTarget: "umd"
}
} else if (define === "TEST") {
base.devtool = "source-map";
base.entry = "./src/test";
} else {
base.devtool = "source-map";
base.entry = "./src/dev";
}
return base;
};