-
Notifications
You must be signed in to change notification settings - Fork 18
/
webpack.config.js
109 lines (108 loc) · 3.16 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
97
98
99
100
101
102
103
104
105
106
107
108
109
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
require('dotenv').config();
module.exports = env => {
const isEnvProduction = !!env && env.production;
console.log('Production: ', isEnvProduction);
return {
devtool: 'cheap-module-eval-source-map',
entry: './src/index.jsx',
devtool: 'source-map', //eval | source-map
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.(scss|less|css)$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
use: [
{
loader: 'file-loader',
},
],
},
],
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: '100ms-conference.[hash].js',
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin(
Object.assign(
{},
{
inject: true,
template: path.resolve(__dirname, 'public/index.html'),
},
isEnvProduction
? {
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
}
: undefined
)
),
new webpack.DefinePlugin({
'process.env.FIREBASE_API_KEY': JSON.stringify(
process.env.FIREBASE_API_KEY
),
'process.env.FIREBASE_AUTH_DOMAIN': JSON.stringify(
process.env.FIREBASE_AUTH_DOMAIN
),
'process.env.FIREBASE_DATABASE_URL': JSON.stringify(
process.env.FIREBASE_DATABASE_URL
),
'process.env.FIREBASE_PROJECT_ID': JSON.stringify(
process.env.FIREBASE_PROJECT_ID
),
'process.env.FIREBASE_STORAGE_BUCKET': JSON.stringify(
process.env.FIREBASE_STORAGE_BUCKET
),
'process.env.FIREBASE_MESSAGING_ID': JSON.stringify(
process.env.FIREBASE_MESSAGING_ID
),
'process.env.FIREBASE_APP_ID': JSON.stringify(
process.env.FIREBASE_APP_ID
),
'process.env.FIREBASE_MEASUREMENT_ID': JSON.stringify(
process.env.FIREBASE_MEASUREMENT_ID
),
'process.env.TOKEN_ENDPOINT': JSON.stringify(
process.env.TOKEN_ENDPOINT
),
'process.env.CREATE_ROOM_ENDPOINT': JSON.stringify(
process.env.CREATE_ROOM_ENDPOINT
),
'process.env.HMS_ENDPOINT': JSON.stringify(process.env.HMS_ENDPOINT),
}),
],
devServer: {
hot: true,
},
};
};