This repository has been archived by the owner on Jan 16, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
webpack.config.js
61 lines (58 loc) · 1.68 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
const webpack = require("webpack")
const UglifyJsPlugin = require("uglifyjs-webpack-plugin")
const isProduction = process.env.NODE_ENV == "production"
module.exports = {
mode: isProduction ? "production": "development",
entry: "./src/client/index.ts",
output: {
path: __dirname+"/dist/client",
filename: "bundle.js",
publicPath: "/assets/",
},
externals: {
react: "React",
"react-dom": "ReactDOM",
"react-router-dom": "ReactRouterDOM",
"reactstrap": "Reactstrap",
jquery: "jQuery",
moment: "moment",
"popper.js": "Popper",
},
devServer: {
contentBase: "dist/client",
proxy: {
"/": "http://localhost:"+(process.env.BACK_PORT || 3000)
},
},
plugins: [
new webpack.ProvidePlugin({
apiFetch: __dirname+"/src/client/api-fetch.ts"
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
module: {
rules: [
{test: /\.css$/, loader: 'style-loader!css-loader'},
{test: /\.(woff2?|ttf|eot|svg)$/, loader: 'file-loader'},
{test: /\.tsx?$/, loader: isProduction ? 'babel-loader!ts-loader' : 'ts-loader'},
]
},
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
optimization: {
minimizer: isProduction ? [
new UglifyJsPlugin({
uglifyOptions: {
keep_classnames: true
}
})
]: []
}
}
// if (process.env.NODE_ENV == "production") {
// module.exports.plugins.push(new UglifyJsPlugin({
// }))
// }