-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathwebpack.config.js
More file actions
124 lines (123 loc) · 4.69 KB
/
webpack.config.js
File metadata and controls
124 lines (123 loc) · 4.69 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
const path = require("path");
const webpackMerge = require("webpack-merge");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const WorkboxPlugin = require('workbox-webpack-plugin');
const SourceMapPlugin = require('webpack').SourceMapDevToolPlugin;
const DefinePlugin = require('webpack').DefinePlugin;
const modeConfiguration = mode => require(`./build-utils/webpack.${mode}`)(mode);
module.exports = (env, argv) => {
console.log(`mode is: ${argv.mode}`);
return webpackMerge(
{
mode: argv.mode,
entry: "./src/index.tsx",
devtool: "source-map",
output: {
publicPath: "/",
path: path.resolve(__dirname, "build"),
filename: "bundled.[hash].js",
},
node: {
net: 'empty',
fs: 'empty',
tls: 'empty',
},
devServer:{
historyApiFallback: true,
contentBase: './',
hot: true
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json']
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
}
},
/* {
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
}, */
{//Should remove this rule after JS Migration to TS is Done.
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
cacheDirectory: true,
}
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-url-loader',
options: {
limit: 100000,
name: '[path][name].[ext]',
encoding: 'base64'
},
},
],
},
{
test:/\.(png|jpg|gif)$/,
loader: 'url-loader',
options: {
limit: 8192,
name: '[path][name].[ext]',
},
},
{
test: /\.css$/,
use : [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
sourceMap: true,
}
}
]
},
{
test: /\.(woff(2)?|ttf|eot|pdf|pptx|docx)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
}
}
]
}
]
},
plugins: [
new DefinePlugin({
'process.env.USE_LOCAL_FIRESTORE': process.env.REACT_APP_USE_LOCAL_FIRESTORE === 'true',
'process.env.USE_LOCAL_FUNCTIONS': process.env.REACT_APP_USE_LOCAL_FUNCTIONS === 'true',
'process.env.USE_LOCAL_AUTH' : process.env.REACT_APP_USE_LOCAL_AUTH === 'true',
'process.env.FIREBASE_CONFIG' : process.env.REACT_APP_FIREBASE_CONFIG
}),
new HtmlWebpackPlugin({
template: "./public/template/index.html"
}),
new WorkboxPlugin.GenerateSW({
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling "old" SWs to hang around
clientsClaim: true,
skipWaiting: true,
}),
]
},
modeConfiguration(argv.mode)
);
};