-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
96 lines (78 loc) · 2.49 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
let webpack = require("webpack"),//build tool, minification and bundling tool
path = require("path"),
DIST_DIR = path.resolve(__dirname,"dist"), // distribution directory
SRC_DIR = path.resolve(__dirname,"src"), // source directory
UglifyJSPlugin = require('uglifyjs-webpack-plugin'),
webpackConfig = {
//entry
entry: SRC_DIR+"/index.js",
//out put
output:{
path: DIST_DIR + "/app",
filename: "bundle.js",
publicPath:"/app/"
},
//modules
module:{
rules:[
{
test:/\.js?/,
include:SRC_DIR,
loader: "babel-loader",
enforce: 'pre',
query: {
presets: ["@babel/preset-env", "@babel/react"],
plugins: [
"@babel/plugin-proposal-class-properties"
]
}
},
{
test:/\.(css)$/,
include:SRC_DIR,
use:['style-loader','css-loader']
},
],
},
optimization: {
minimizer: [
new UglifyJSPlugin({
test: /\.js(\?.*)?$/i,
//include: /\/includes/,
//exclude: /\/excludes/,
cache: true,
sourceMap: true
}),
],
},
resolve: {
extensions: ['.js', '.jsx']
},
devServer: { //this is to configure our webpack-dev-server to serve http requests
contentBase:[
path.join(DIST_DIR),
path.join(SRC_DIR),
// and so on...
] ,//__dirname+"/dist",
//hot: true,
inline: true,
host: "localhost",
//host: "local.synergiticit.com",
port:9092,
// https: true,
//for supporting history api fallback
historyApiFallback: { //localhost:9092/home
index: '/'
},
//compress: true,
// 'Live-reloading' happens when you make changes to code
// dependency pointed to by 'entry' parameter explained earlier.
// To make live-reloading happen even when changes are made
// to the static html pages in 'contentBase', add
// 'watchContentBase'
watchContentBase: true
},
//devtool: 'source-map', //this will give us a copy of human readable format of files basically all files that we used
//mode: 'production'
}
module.exports = webpackConfig;