@epilot360/webpack-config-epilot360 2.5.6 → 2.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/env.js +44 -0
- package/lib/webpack-config-epilot360-portal.js +7 -2
- package/package.json +1 -1
package/lib/env.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const REACT_APP = /^REACT_APP_/i;
|
|
2
|
+
|
|
3
|
+
function getClientEnvironment(publicUrl) {
|
|
4
|
+
const raw = Object.keys(process.env)
|
|
5
|
+
.filter(key => REACT_APP.test(key))
|
|
6
|
+
.reduce(
|
|
7
|
+
(env, key) => {
|
|
8
|
+
env[key] = process.env[key];
|
|
9
|
+
return env;
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
// Useful for determining whether we’re running in production mode.
|
|
13
|
+
// Most importantly, it switches React into the correct mode.
|
|
14
|
+
NODE_ENV: process.env.NODE_ENV || 'development',
|
|
15
|
+
// Useful for resolving the correct path to static assets in `public`.
|
|
16
|
+
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
|
|
17
|
+
// This should only be used as an escape hatch. Normally you would put
|
|
18
|
+
// images into the `src` and `import` them in code to get their paths.
|
|
19
|
+
PUBLIC_URL: publicUrl,
|
|
20
|
+
// We support configuring the sockjs pathname during development.
|
|
21
|
+
// These settings let a developer run multiple simultaneous projects.
|
|
22
|
+
// They are used as the connection `hostname`, `pathname` and `port`
|
|
23
|
+
// in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
|
|
24
|
+
// and `sockPort` options in webpack-dev-server.
|
|
25
|
+
WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
|
|
26
|
+
WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
|
|
27
|
+
WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
|
|
28
|
+
// Whether or not react-refresh is enabled.
|
|
29
|
+
// It is defined here so it is available in the webpackHotDevClient.
|
|
30
|
+
FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
// Stringify all values so we can feed into webpack DefinePlugin
|
|
34
|
+
const stringified = {
|
|
35
|
+
'process.env': Object.keys(raw).reduce((env, key) => {
|
|
36
|
+
env[key] = JSON.stringify(raw[key]);
|
|
37
|
+
return env;
|
|
38
|
+
}, {}),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return { raw, stringified };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = getClientEnvironment;
|
|
@@ -9,6 +9,7 @@ const StandaloneSingleSpaPlugin = require("standalone-single-spa-webpack-plugin"
|
|
|
9
9
|
const SystemJSPublicPathPlugin = require("systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin");
|
|
10
10
|
const { ESBuildMinifyPlugin } = require('esbuild-loader')
|
|
11
11
|
const resolveCwd = require('resolve-cwd');
|
|
12
|
+
const env = require('./env')()
|
|
12
13
|
|
|
13
14
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
|
14
15
|
|
|
@@ -53,10 +54,14 @@ function webpackConfigEpilot360ReactApp(opts) {
|
|
|
53
54
|
const legacyEntrypoint = path.resolve(
|
|
54
55
|
process.cwd(),
|
|
55
56
|
'src',
|
|
56
|
-
`${opts.orgName}-${opts.projectName}.
|
|
57
|
+
`${opts.orgName}-${opts.projectName}.ts`
|
|
57
58
|
)
|
|
58
59
|
|
|
59
|
-
const fileExists = (path) =>
|
|
60
|
+
const fileExists = (path) => {
|
|
61
|
+
if (fs.existsSync(path)) return path
|
|
62
|
+
if (fs.existsSync(path + 'x')) return path + 'x'
|
|
63
|
+
return null
|
|
64
|
+
}
|
|
60
65
|
|
|
61
66
|
return {
|
|
62
67
|
mode: isProduction ? "production" : "development",
|
package/package.json
CHANGED