This repository has been archived by the owner on May 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.client.config.js
58 lines (51 loc) · 1.72 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
*/
/*
* Creates "client-bundle.js" for the client containing just the React App.
*
* This is created so that event handlers coded in JavaScript are available on the client browser.
*/
const path = require('path');
const { merge } = require('webpack-merge');
const CopyPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const baseConfig = require('./webpack.base.config.js');
const config = {
// do not need a 'target' as this is for the browser
// tell WebPack the root file of our client application
// usually the root file is "index.js" enabling just the client directory to be imported,
// but specifically naming it "client.js" makes it a lot clearer that this file will only
// run on the client.
entry: './src/client/client.jsx',
// tell WebPack the name of the generated output file and where to put it, its placed in the
// "public" directory as it needs to be publically available to anyone who asks for it
output: {
filename: 'client-bundle.js',
path: path.resolve(__dirname, 'public'),
},
plugins: [
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, 'src', 'styles'),
to: path.resolve(__dirname, 'public'),
},
],
}),
new webpack.DefinePlugin({
'process.env.IS_BROWSER': true,
}),
],
resolve: {
fallback: {
fs: false,
path: false,
url: false,
events: false,
},
},
};
// merge the base config and this config together to produce the full client config
module.exports = merge(baseConfig, config);