-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.common.js
72 lines (71 loc) · 2.07 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
const HtmlWebPackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
externals: {
// global app config object
config: JSON.stringify({
appUrl: process.env.APP_URL,
clientId: process.env.CLIENT_ID,
vapidKey: process.env.VAPID_KEY,
}),
},
module: {
rules: [
{
/*
* pass all javascript files through babel
* this compiles the JSX and converts ES6 code into regular JS
*/
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.html$/,
use: {
loader: "html-loader",
},
},
],
},
/*
* specify how the final JS is injected into the html document
*/
plugins: [
new HtmlWebPackPlugin({
chunks: ["landing"],
favicon: "./src/assets/favicon.ico",
template: "./src/index.ejs",
filename: "./index.html",
templateParameters: {
appUrl: process.env.APP_URL,
},
}),
new HtmlWebPackPlugin({
chunks: ["app"],
template: "./src/app.ejs",
filename: "./spotify/index.html",
}),
new HtmlWebPackPlugin({
chunks: ["faq"],
template: "./src/faq.ejs",
filename: "./faq/index.html",
templateParameters: {
appUrl: process.env.APP_URL,
},
}),
new CopyWebpackPlugin({
patterns: [
{from: "./src/assets"},
],
}),
],
entry: {
landing: ["babel-polyfill", "./src/index.js"],
app: ["babel-polyfill", "./src/spotify.js"],
faq: ["babel-polyfill", "./src/faq.js"],
"service-worker": ["babel-polyfill", "./src/service-worker.js"],
},
};