-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.client.config.js
40 lines (34 loc) · 1.02 KB
/
webpack.client.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
const webpack = require('webpack')
require('dotenv').config()
const path = require('path')
const webpackMerge = require('webpack-merge')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const modeConfig = env => require(`./build-utils/webpack.client.${env}`)(env)
const presetConfig = require("./build-utils/loadPresets")
module.exports = ({ mode, presets } = { mode: "production", presets: [] }) => {
console.log(`Building for: ${mode}`)
return webpackMerge(
{
mode,
entry: {
main: path.join(__dirname, './src/client/index.js')
},
plugins: [
new HtmlWebpackPlugin({
template: 'public/index.html',
inject: 'body',
filename: 'index.html',
}),
new webpack.EnvironmentPlugin([
'PORT', 'API_URL'
]),
new CopyWebpackPlugin([
{ from: 'public/favicon.ico' }
]),
]
},
modeConfig(mode),
presetConfig({ mode, presets }),
)
}