-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.common.js
105 lines (99 loc) · 2.67 KB
/
webpack.common.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
105
var path = require('path');
const {
merge
} = require('webpack-merge');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var WriteFilePlugin = require('write-file-webpack-plugin');
var WebpackShellPlugin = require('webpack-shell-plugin');
const productionConfig = merge([{
output: {
publicPath: "/chat-component-app-live-event/",
},
}]);
module.exports = {
// webpack will take the files from ./src/index
entry: './src/index',
// and output it into /dist as bundle.js
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.js',
publicPath: '/'
},
devServer: {
inline: true,
host: '0.0.0.0', //Listen on all interfaces so local lan browser can access.
port: 8080, //port number where to run run the web app i.e.: http://localhost:8080
historyApiFallback: true,
bonjour: true,
},
// adding .ts and .tsx to resolve.extensions will help babel look for .ts and .tsx files to transpile
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
module: {
rules: [
// we use babel-loader to load our jsx and tsx files
{
test: /\.(ts|js)x?$/,
//exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
// css-loader to bundle all the css files into one file and style-loader to add all the styles inside the style tag of the document
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|svg|jpg|jpeg|gif|ico)$/,
exclude: /node_modules/,
use: ['file-loader?name=[name].[ext]'] // ?name=[name].[ext] is only necessary to preserve the original file name
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
},
{
test: /\.(png|svg|jpg|gif|woff|woff2|eot|ttf|otf)$/,
use: [
'file-loader',
],
},
{
test: /\.(jpg|png)$/,
use: {
loader: 'url-loader',
},
},
]
},
node: {
fs: 'empty'
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
favicon: './public/favicon.ico'
}),
new CopyWebpackPlugin({
patterns: [{
from: 'src/img',
to: 'images'
}],
}),
new WriteFilePlugin({
patterns: [{
from: 'src/img',
to: 'images'
}],
}),
new WebpackShellPlugin({
onBuildStart: ['echo "Starting Live Event Demo Server..."'],
//onBuildEnd: [`node src/tools/ngrok.js 8080`]
})
]
};