-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
81 lines (79 loc) · 2.07 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
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const StatsVisualizerPlugin = require("webpack-visualizer-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const config = {
entry: "./src/index.js",
output: {
path: `${__dirname}/build`,
filename: "[name].[hash].js"
},
module: {
rules: [
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/, /Stylesheets\.elm$/],
use: process.env.DEBUG
? ["elm-hot-loader", "elm-webpack-loader?debug=true"]
: ["elm-webpack-loader"]
},
{
test: /Stylesheets\.elm$/,
use: ["style-loader", "css-loader?url=false", "elm-css-webpack-loader"]
},
{
test: /\.html$/,
use: ["raw-loader"]
}
]
},
devServer: {
host: "0.0.0.0",
disableHostCheck: true
},
plugins: [
new webpack.EnvironmentPlugin({
DEBUG: !!process.env.DEBUG,
FIREBASE_API_KEY: "AIzaSyDfwHLwWKTqduazsf4kjbstJEA2E1sCeoI",
FIREBASE_AUTH_DOMAIN: "caronaboard-61f75.firebaseapp.com",
FIREBASE_DATABASE_URL: "https://caronaboard-61f75.firebaseio.com",
FIREBASE_STORAGE_BUCKET: "caronaboard-61f75.appspot.com",
FIREBASE_MESSAGING_SENDER_ID: "617045704123"
}),
new HtmlWebpackPlugin({
template: "src/index.ejs"
}),
new CopyWebpackPlugin([
{
from: "src/static",
to: "static"
}
]),
new CopyWebpackPlugin([
{
from: "src/firebase-messaging-sw.js",
to: "",
transform: content =>
content
.toString()
.replace(
"process.env.FIREBASE_MESSAGING_SENDER_ID",
`"${process.env.FIREBASE_MESSAGING_SENDER_ID}"`
)
}
])
].concat(
process.env.DEBUG
? []
: [
new UglifyJsPlugin({
uglifyOptions: {
ecma: 6
}
}),
new StatsVisualizerPlugin()
]
)
};
module.exports = config;