@reactunity/scripts 0.9.1 → 0.12.0
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/README.md +7 -3
- package/bin/react-unity-scripts.js +2 -1
- package/config/env.js +1 -1
- package/config/paths.js +7 -0
- package/config/{web-inspector → public}/.gitignore +0 -0
- package/config/{web-inspector → public}/favicon.ico +0 -0
- package/config/public/index.html +78 -0
- package/config/webpack.config.js +69 -5
- package/config/webpackDevServer.config.js +23 -6
- package/package.json +48 -51
- package/scripts/build.js +3 -15
- package/scripts/clean.js +34 -0
- package/scripts/utils/cleanBuildDirectory.js +76 -0
- package/config/web-inspector/Build/WebInspector.data +0 -0
- package/config/web-inspector/Build/WebInspector.framework.js +0 -7
- package/config/web-inspector/Build/WebInspector.loader.js +0 -1
- package/config/web-inspector/Build/WebInspector.wasm +0 -0
- package/config/web-inspector/index.html +0 -86
package/README.md
CHANGED
|
@@ -25,15 +25,19 @@ Environment variables of CRA can be used with React Unity. However, there are so
|
|
|
25
25
|
- `FILENAME` - Name of the generated javascript file. `index.js` by default.
|
|
26
26
|
- `BUILD_PATH` - Path to the generated output. Relative to the project. `../Assets/Resources/react` by default.
|
|
27
27
|
- `GENERATE_SOURCEMAP` - `false` by default.
|
|
28
|
-
- `
|
|
28
|
+
- `FAST_REFRESH` - This can be set to `false` to disable `react-refresh` if you are having problems with hot reload
|
|
29
29
|
- `IMAGE_INLINE_SIZE_LIMIT` - `0` by default. Because non-inlined images will be faster in Unity. However, if users still want to inline images, they should increase this limit.
|
|
30
30
|
|
|
31
31
|
Environment variables can also be defined by having `.env`, `.env.local`, `.env.<development|production>` in project folder.
|
|
32
32
|
|
|
33
33
|
Custom environment variables are also possible as in [CRA](https://create-react-app.dev/docs/adding-custom-environment-variables).
|
|
34
34
|
|
|
35
|
+
## Multiple Entry Points
|
|
36
|
+
|
|
37
|
+
In addition to `src/index` file, there can be other entry points. Every file under `src/entry/` folder will be detected and configured as an entry point. For example, if there is a file `src/entry/menu.tsx`, Webpack will detect that and create an entrypoint named `menu` with output `menu.js` in addition to the default entrypoint `index.js`.
|
|
38
|
+
|
|
35
39
|
## WebGL Inspector
|
|
36
40
|
|
|
37
|
-
When dev server is started with the `start` script, a web server is launched at the selected port (e.g. http://localhost:3000). This server serves the javascript and asset files that are used by ReactUnity. If you visit this link in browser, you will see a
|
|
41
|
+
When dev server is started with the `start` script, a web server is launched at the selected port (e.g. http://localhost:3000). This server serves the javascript and asset files that are used by ReactUnity. If you visit this link in browser, you will see a page explaining how to setup the web previewer. The previewer can be used to quickly test the React code without even launching Unity. It also reacts to the changes in code by utilizing HMR.
|
|
38
42
|
|
|
39
|
-
Note that this web inspector has very limited capabilities. Naturally, it may not work for all cases. However it is a useful tool for when starting a new ReactUnity project. As an advanced feature, you can override the web inspector by placing your custom web inspector in `
|
|
43
|
+
Note that this web inspector has very limited capabilities. Naturally, it may not work for all cases. However it is a useful tool for when starting a new ReactUnity project. As an advanced feature, you can override the web inspector by placing your custom web inspector in `previewer` folder under your React project.
|
|
@@ -24,12 +24,13 @@ const scriptIndex = args.findIndex(
|
|
|
24
24
|
x === 'eject' ||
|
|
25
25
|
x === 'start' ||
|
|
26
26
|
x === 'test' ||
|
|
27
|
+
x === 'clean' ||
|
|
27
28
|
x === 'lint'
|
|
28
29
|
);
|
|
29
30
|
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
|
30
31
|
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
|
|
31
32
|
|
|
32
|
-
if (['build', 'eject', 'start', 'test', 'lint'].includes(script)) {
|
|
33
|
+
if (['build', 'eject', 'start', 'test', 'clean', 'lint'].includes(script)) {
|
|
33
34
|
const result = spawn.sync(
|
|
34
35
|
process.execPath,
|
|
35
36
|
nodeArgs
|
package/config/env.js
CHANGED
|
@@ -95,7 +95,7 @@ function getClientEnvironment(publicUrl) {
|
|
|
95
95
|
WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
|
|
96
96
|
// Whether or not react-refresh is enabled.
|
|
97
97
|
// It is defined here so it is available in the webpackHotDevClient.
|
|
98
|
-
FAST_REFRESH: process.env.FAST_REFRESH
|
|
98
|
+
FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
|
|
99
99
|
}
|
|
100
100
|
);
|
|
101
101
|
// Stringify all values so we can feed into webpack DefinePlugin
|
package/config/paths.js
CHANGED
|
@@ -30,6 +30,7 @@ const publicUrlOrPath = getPublicUrlOrPath(
|
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
const buildPath = process.env.BUILD_PATH || '../Assets/Resources/react';
|
|
33
|
+
const manifestPath = path.join(buildPath, 'asset-manifest.json');
|
|
33
34
|
|
|
34
35
|
const moduleFileExtensions = [
|
|
35
36
|
'web.mjs',
|
|
@@ -63,7 +64,9 @@ module.exports = {
|
|
|
63
64
|
dotenv: resolveApp('.env'),
|
|
64
65
|
appPath: resolveApp('.'),
|
|
65
66
|
appBuild: resolveApp(buildPath),
|
|
67
|
+
appManifest: resolveApp(manifestPath),
|
|
66
68
|
appPublic: resolveApp('public'),
|
|
69
|
+
appPublicAlt: resolveApp('previewer'),
|
|
67
70
|
appHtml: resolveApp('public/index.html'),
|
|
68
71
|
appIndexJs: resolveModule(resolveApp, 'src/index'),
|
|
69
72
|
appPackageJson: resolveApp('package.json'),
|
|
@@ -89,7 +92,9 @@ module.exports = {
|
|
|
89
92
|
dotenv: resolveApp('.env'),
|
|
90
93
|
appPath: resolveApp('.'),
|
|
91
94
|
appBuild: resolveApp(buildPath),
|
|
95
|
+
appManifest: resolveApp(manifestPath),
|
|
92
96
|
appPublic: resolveApp('public'),
|
|
97
|
+
appPublicAlt: resolveApp('previewer'),
|
|
93
98
|
appHtml: resolveApp('public/index.html'),
|
|
94
99
|
appIndexJs: resolveModule(resolveApp, 'src/index'),
|
|
95
100
|
appPackageJson: resolveApp('package.json'),
|
|
@@ -128,7 +133,9 @@ if (
|
|
|
128
133
|
dotenv: resolveOwn(`${templatePath}/.env`),
|
|
129
134
|
appPath: resolveApp('.'),
|
|
130
135
|
appBuild: resolveOwn(path.join('../..', buildPath)),
|
|
136
|
+
appManifest: resolveOwn(path.join('../..', manifestPath)),
|
|
131
137
|
appPublic: resolveOwn(`${templatePath}/public`),
|
|
138
|
+
appPreviewer: resolveOwn(`${templatePath}/previewer`),
|
|
132
139
|
appHtml: resolveOwn(`${templatePath}/public/index.html`),
|
|
133
140
|
appIndexJs: resolveModule(resolveOwn, `${templatePath}/src/index`),
|
|
134
141
|
appPackageJson: resolveOwn('package.json'),
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en-us">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
+
|
|
9
|
+
<title>ReactUnity</title>
|
|
10
|
+
|
|
11
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
12
|
+
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
|
13
|
+
</head>
|
|
14
|
+
|
|
15
|
+
<body>
|
|
16
|
+
|
|
17
|
+
<div class="col-lg-8 mx-auto p-3 py-md-5">
|
|
18
|
+
<header class="d-flex align-items-center pb-3 mb-5 border-bottom">
|
|
19
|
+
<a href="/" class="d-flex align-items-center text-dark text-decoration-none">
|
|
20
|
+
<img src="./favicon.ico" height="72" class="me-3" />
|
|
21
|
+
<span class="fs-1">ReactUnity Previewer</span>
|
|
22
|
+
</a>
|
|
23
|
+
</header>
|
|
24
|
+
|
|
25
|
+
<main>
|
|
26
|
+
<p class="fs-5 col-md-8">
|
|
27
|
+
Congratulations on starting your ReactUnity project. You can now test your app inside Unity by setting the
|
|
28
|
+
<code>DevServer</code> property of <code>ReactUnityUGUI</code> or <code>ReactUnityUIToolkit</code> components to
|
|
29
|
+
the address of this page.
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<p class="fs-5 col-md-8">
|
|
33
|
+
If your UI is simple, you can also test your UI inside this page with a WebGL template. There are 2 ways you can
|
|
34
|
+
do that.
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<div class="alert alert-warning d-flex align-items-center" role="alert">
|
|
38
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor"
|
|
39
|
+
class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" viewBox="0 0 16 16" role="img"
|
|
40
|
+
aria-label="Warning:">
|
|
41
|
+
<path
|
|
42
|
+
d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z" />
|
|
43
|
+
</svg>
|
|
44
|
+
<div class="fs-5">
|
|
45
|
+
Note that as ReactUnity is not optimized for WebGL, you will have a low performance by testing in WebGL.
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<h4>1 - Install the default previewer</h4>
|
|
50
|
+
|
|
51
|
+
<p class="fs-5 col-md-8">
|
|
52
|
+
You can install the <code>@reactunity/previewer</code> package for this.
|
|
53
|
+
</p>
|
|
54
|
+
|
|
55
|
+
<pre>
|
|
56
|
+
yarn add --dev @reactunity/previewer
|
|
57
|
+
# OR
|
|
58
|
+
npm i --D @reactunity/previewer
|
|
59
|
+
</pre>
|
|
60
|
+
|
|
61
|
+
<h4>2 - Use a custom previewer</h4>
|
|
62
|
+
|
|
63
|
+
<p class="fs-5 col-md-8">
|
|
64
|
+
To do this, you need to build a scene in Unity with <code>ReactUnityUGUI</code> component added. The
|
|
65
|
+
<code>Type</code> property must be set to <code>Url</code> and <code>Source Path</code> property must be set to
|
|
66
|
+
<code>/index.js</code>.
|
|
67
|
+
|
|
68
|
+
After building, you must copy the built directory to <code>previewer</code> folder inside your React project, so
|
|
69
|
+
that there is a <code>previewer/index.html</code> file.
|
|
70
|
+
</p>
|
|
71
|
+
</main>
|
|
72
|
+
|
|
73
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js"
|
|
74
|
+
integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF"
|
|
75
|
+
crossorigin="anonymous"></script>
|
|
76
|
+
</body>
|
|
77
|
+
|
|
78
|
+
</html>
|
package/config/webpack.config.js
CHANGED
|
@@ -74,12 +74,39 @@ const useTailwind = fs.existsSync(
|
|
|
74
74
|
path.join(paths.appPath, 'tailwind.config.js')
|
|
75
75
|
);
|
|
76
76
|
|
|
77
|
+
const warnedAboutPlugin = {};
|
|
78
|
+
const usePostcssPluginIfExists = (name, options = {}) => {
|
|
79
|
+
try {
|
|
80
|
+
if (require.resolve(name)) {
|
|
81
|
+
if (!warnedAboutPlugin[name]) {
|
|
82
|
+
console.log('Using plugin ' + name);
|
|
83
|
+
warnedAboutPlugin[name] = true;
|
|
84
|
+
}
|
|
85
|
+
return { [name]: options };
|
|
86
|
+
}
|
|
87
|
+
} catch (err) { }
|
|
88
|
+
return {};
|
|
89
|
+
};
|
|
90
|
+
|
|
77
91
|
// style files regexes
|
|
78
92
|
const cssRegex = /\.css$/;
|
|
79
93
|
const cssModuleRegex = /\.module\.css$/;
|
|
80
94
|
const sassRegex = /\.(scss|sass)$/;
|
|
81
95
|
const sassModuleRegex = /\.module\.(scss|sass)$/;
|
|
82
96
|
|
|
97
|
+
|
|
98
|
+
// Treat files under `src/entry` as separate entry points
|
|
99
|
+
const appDirectory = fs.realpathSync(process.cwd());
|
|
100
|
+
const entryDirectory = path.join(appDirectory, 'src/entry');
|
|
101
|
+
const entries = !fs.existsSync(entryDirectory) ? [] :
|
|
102
|
+
fs.readdirSync(entryDirectory, { withFileTypes: true })
|
|
103
|
+
.filter(x => x.isFile())
|
|
104
|
+
.filter(x => /\.(js|mjs|jsx|ts|tsx)$/.test(x.name))
|
|
105
|
+
.map(x => path.resolve(entryDirectory, x.name));
|
|
106
|
+
const entryObj = {};
|
|
107
|
+
for (const entry of entries) entryObj[path.basename(entry, path.extname(entry))] = entry;
|
|
108
|
+
|
|
109
|
+
|
|
83
110
|
// This is the production and development configuration.
|
|
84
111
|
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
|
85
112
|
const baseConfigFactory = function (webpackEnv) {
|
|
@@ -127,7 +154,13 @@ const baseConfigFactory = function (webpackEnv) {
|
|
|
127
154
|
// https://github.com/facebook/create-react-app/issues/2677
|
|
128
155
|
ident: 'postcss',
|
|
129
156
|
config: false,
|
|
130
|
-
plugins:
|
|
157
|
+
plugins: {
|
|
158
|
+
...usePostcssPluginIfExists('postcss-import'),
|
|
159
|
+
'tailwindcss': {},
|
|
160
|
+
...usePostcssPluginIfExists('postcss-nesting'),
|
|
161
|
+
...usePostcssPluginIfExists('postcss-custom-properties'),
|
|
162
|
+
...usePostcssPluginIfExists('postcss-css-variables'),
|
|
163
|
+
},
|
|
131
164
|
},
|
|
132
165
|
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
133
166
|
},
|
|
@@ -164,15 +197,18 @@ const baseConfigFactory = function (webpackEnv) {
|
|
|
164
197
|
: isEnvDevelopment && (sourceMapType || 'eval-source-map'),
|
|
165
198
|
// These are the "entry points" to our application.
|
|
166
199
|
// This means they will be the "root" imports that are included in JS bundle.
|
|
167
|
-
entry:
|
|
200
|
+
entry: {
|
|
201
|
+
index: paths.appIndexJs,
|
|
202
|
+
...entryObj,
|
|
203
|
+
},
|
|
168
204
|
output: {
|
|
169
205
|
// The build folder.
|
|
170
206
|
path: paths.appBuild,
|
|
171
207
|
// Add /* filename */ comments to generated require()s in the output.
|
|
172
208
|
pathinfo: isEnvDevelopment,
|
|
173
|
-
// There
|
|
209
|
+
// There can be multiple entry bundles, and one file per asynchronous chunk.
|
|
174
210
|
// In development, it does not produce real files.
|
|
175
|
-
filename: isEnvDevelopment ? '
|
|
211
|
+
filename: isEnvDevelopment ? '[name].js' : process.env.FILENAME || '[name].js',
|
|
176
212
|
// There are also additional JS chunk files if you use code splitting.
|
|
177
213
|
chunkFilename: isEnvProduction
|
|
178
214
|
? 'static/js/[name].chunk.js'
|
|
@@ -252,6 +288,8 @@ const baseConfigFactory = function (webpackEnv) {
|
|
|
252
288
|
}),
|
|
253
289
|
],
|
|
254
290
|
runtimeChunk: false,
|
|
291
|
+
chunkIds: 'named',
|
|
292
|
+
moduleIds: 'named',
|
|
255
293
|
},
|
|
256
294
|
resolve: {
|
|
257
295
|
// This allows you to set a fallback for where webpack should look for modules.
|
|
@@ -330,6 +368,32 @@ const baseConfigFactory = function (webpackEnv) {
|
|
|
330
368
|
},
|
|
331
369
|
},
|
|
332
370
|
},
|
|
371
|
+
{
|
|
372
|
+
test: /\.svg$/,
|
|
373
|
+
use: [
|
|
374
|
+
{
|
|
375
|
+
loader: require.resolve('@svgr/webpack'),
|
|
376
|
+
options: {
|
|
377
|
+
prettier: false,
|
|
378
|
+
svgo: false,
|
|
379
|
+
svgoConfig: {
|
|
380
|
+
plugins: [{ removeViewBox: false }],
|
|
381
|
+
},
|
|
382
|
+
titleProp: true,
|
|
383
|
+
ref: true,
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
loader: require.resolve('file-loader'),
|
|
388
|
+
options: {
|
|
389
|
+
name: 'static/media/[name].[hash].[ext]',
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
issuer: {
|
|
394
|
+
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
|
|
395
|
+
},
|
|
396
|
+
},
|
|
333
397
|
// Process application JS with Babel.
|
|
334
398
|
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
|
|
335
399
|
{
|
|
@@ -570,7 +634,7 @@ const baseConfigFactory = function (webpackEnv) {
|
|
|
570
634
|
manifest[file.name] = file.path;
|
|
571
635
|
return manifest;
|
|
572
636
|
}, seed);
|
|
573
|
-
const entrypointFiles = entrypoints.
|
|
637
|
+
const entrypointFiles = entrypoints.index.filter(
|
|
574
638
|
fileName => !fileName.endsWith('.map')
|
|
575
639
|
);
|
|
576
640
|
|
|
@@ -23,6 +23,15 @@ const sockHost = process.env.WDS_SOCKET_HOST;
|
|
|
23
23
|
const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
|
|
24
24
|
const sockPort = process.env.WDS_SOCKET_PORT;
|
|
25
25
|
|
|
26
|
+
function servePreviewerIfExists() {
|
|
27
|
+
try {
|
|
28
|
+
const previewerPath = path.dirname(require.resolve('@reactunity/previewer', { paths: [paths.appPath] }));
|
|
29
|
+
console.log('Using @reactunity/previewer');
|
|
30
|
+
return [{ directory: path.join(previewerPath, 'public') }];
|
|
31
|
+
} catch (err) { }
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
module.exports = function (proxy, allowedHost) {
|
|
27
36
|
const disableFirewall =
|
|
28
37
|
!proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
|
|
@@ -54,8 +63,6 @@ module.exports = function (proxy, allowedHost) {
|
|
|
54
63
|
// Enable gzip compression of generated files.
|
|
55
64
|
compress: true,
|
|
56
65
|
static: [
|
|
57
|
-
// Serve React Unity Web Inspector as the index page
|
|
58
|
-
{ directory: path.join(__dirname, 'web-inspector'), },
|
|
59
66
|
{
|
|
60
67
|
// By default WebpackDevServer serves physical files from current directory
|
|
61
68
|
// in addition to all the virtual build products that it serves from memory.
|
|
@@ -82,6 +89,19 @@ module.exports = function (proxy, allowedHost) {
|
|
|
82
89
|
ignored: ignoredFiles(paths.appSrc),
|
|
83
90
|
},
|
|
84
91
|
},
|
|
92
|
+
|
|
93
|
+
// Serve previewer from local previewer directory
|
|
94
|
+
{
|
|
95
|
+
directory: paths.appPreviewer,
|
|
96
|
+
publicPath: [paths.publicUrlOrPath],
|
|
97
|
+
watch: { ignored: ignoredFiles(paths.appSrc) },
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
// If installed, serve the ReactUnity Web Previewer
|
|
101
|
+
...servePreviewerIfExists(),
|
|
102
|
+
|
|
103
|
+
// Serve the fallback of web previewer as the index page
|
|
104
|
+
{ directory: path.join(__dirname, 'public'), },
|
|
85
105
|
],
|
|
86
106
|
|
|
87
107
|
client: {
|
|
@@ -93,10 +113,7 @@ module.exports = function (proxy, allowedHost) {
|
|
|
93
113
|
pathname: sockPath,
|
|
94
114
|
port: sockPort,
|
|
95
115
|
},
|
|
96
|
-
overlay:
|
|
97
|
-
errors: true,
|
|
98
|
-
warnings: false,
|
|
99
|
-
},
|
|
116
|
+
overlay: false,
|
|
100
117
|
},
|
|
101
118
|
devMiddleware: {
|
|
102
119
|
// It is important to tell WebpackDevServer to use the same "publicPath" path as
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactunity/scripts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Configuration and scripts for React Unity.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,82 +44,79 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@babel/core": "^7.
|
|
48
|
-
"@babel/eslint-parser": "^7.
|
|
49
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.
|
|
50
|
-
"@
|
|
51
|
-
"@types/
|
|
52
|
-
"@
|
|
53
|
-
"@typescript-eslint/
|
|
54
|
-
"
|
|
55
|
-
"babel-
|
|
47
|
+
"@babel/core": "^7.18.5",
|
|
48
|
+
"@babel/eslint-parser": "^7.18.2",
|
|
49
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
|
|
50
|
+
"@svgr/webpack": "^6.2.1",
|
|
51
|
+
"@types/react": "^18.0.12",
|
|
52
|
+
"@types/webpack-env": "^1.17.0",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
54
|
+
"@typescript-eslint/parser": "^5.28.0",
|
|
55
|
+
"babel-jest": "^28.1.1",
|
|
56
|
+
"babel-loader": "^8.2.5",
|
|
56
57
|
"babel-plugin-named-asset-import": "^0.3.8",
|
|
57
58
|
"babel-preset-react-app": "^10.0.1",
|
|
58
59
|
"bfj": "^7.0.2",
|
|
59
|
-
"camelcase": "^
|
|
60
|
+
"camelcase": "^7.0.0",
|
|
60
61
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
61
62
|
"confusing-browser-globals": "^1.0.11",
|
|
62
|
-
"css-loader": "^6.
|
|
63
|
-
"dotenv": "^16.0.
|
|
64
|
-
"dotenv-expand": "^8.0.
|
|
65
|
-
"eslint": "^8.
|
|
66
|
-
"eslint-plugin-import": "^2.
|
|
67
|
-
"eslint-plugin-jest": "^26.
|
|
68
|
-
"eslint-plugin-react": "^7.
|
|
69
|
-
"eslint-plugin-react-hooks": "^4.
|
|
70
|
-
"eslint-plugin-testing-library": "^5.
|
|
63
|
+
"css-loader": "^6.7.1",
|
|
64
|
+
"dotenv": "^16.0.1",
|
|
65
|
+
"dotenv-expand": "^8.0.3",
|
|
66
|
+
"eslint": "^8.17.0",
|
|
67
|
+
"eslint-plugin-import": "^2.26.0",
|
|
68
|
+
"eslint-plugin-jest": "^26.5.3",
|
|
69
|
+
"eslint-plugin-react": "^7.30.0",
|
|
70
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
71
|
+
"eslint-plugin-testing-library": "^5.5.1",
|
|
71
72
|
"eslint-webpack-plugin": "^3.1.1",
|
|
72
73
|
"file-loader": "^6.2.0",
|
|
73
|
-
"fs-extra": "^10.
|
|
74
|
+
"fs-extra": "^10.1.0",
|
|
74
75
|
"identity-obj-proxy": "^3.0.0",
|
|
75
|
-
"jest": "^
|
|
76
|
-
"jest-resolve": "^
|
|
77
|
-
"jest-watch-typeahead": "^1.
|
|
78
|
-
"mini-css-extract-plugin": "^2.
|
|
76
|
+
"jest": "^28.1.1",
|
|
77
|
+
"jest-resolve": "^28.1.1",
|
|
78
|
+
"jest-watch-typeahead": "^1.1.0",
|
|
79
|
+
"mini-css-extract-plugin": "^2.6.0",
|
|
79
80
|
"null-loader": "^4.0.1",
|
|
80
|
-
"postcss": "^8.4.
|
|
81
|
-
"postcss-loader": "^
|
|
81
|
+
"postcss": "^8.4.14",
|
|
82
|
+
"postcss-loader": "^7.0.0",
|
|
82
83
|
"prompts": "^2.4.2",
|
|
83
84
|
"raw-loader": "^4.0.2",
|
|
84
85
|
"react-app-polyfill": "^3.0.0",
|
|
85
|
-
"react-dev-utils": "^12.0.
|
|
86
|
-
"react-refresh": "^0.
|
|
86
|
+
"react-dev-utils": "^12.0.1",
|
|
87
|
+
"react-refresh": "^0.14.0",
|
|
87
88
|
"resolve": "^1.22.0",
|
|
88
89
|
"resolve-url-loader": "^5.0.0",
|
|
89
|
-
"sass": "^1.
|
|
90
|
-
"sass-loader": "^
|
|
91
|
-
"semver": "^7.3.
|
|
92
|
-
"source-map-loader": "^
|
|
90
|
+
"sass": "^1.52.3",
|
|
91
|
+
"sass-loader": "^13.0.0",
|
|
92
|
+
"semver": "^7.3.7",
|
|
93
|
+
"source-map-loader": "^4.0.0",
|
|
93
94
|
"style-loader": "^3.3.1",
|
|
94
|
-
"tailwindcss": "^3.
|
|
95
|
-
"terser-webpack-plugin": "^5.3.
|
|
95
|
+
"tailwindcss": "^3.1.3",
|
|
96
|
+
"terser-webpack-plugin": "^5.3.3",
|
|
96
97
|
"url-loader": "^4.1.1",
|
|
97
|
-
"webpack": "^5.
|
|
98
|
-
"webpack-dev-server": "^4.
|
|
99
|
-
"webpack-manifest-plugin": "^
|
|
98
|
+
"webpack": "^5.73.0",
|
|
99
|
+
"webpack-dev-server": "^4.9.2",
|
|
100
|
+
"webpack-manifest-plugin": "^5.0.0"
|
|
100
101
|
},
|
|
101
102
|
"devDependencies": {
|
|
102
|
-
"typescript": "^4.
|
|
103
|
+
"typescript": "^4.7.3"
|
|
103
104
|
},
|
|
104
105
|
"optionalDependencies": {
|
|
105
106
|
"fsevents": "^2.3.2"
|
|
106
107
|
},
|
|
107
108
|
"peerDependencies": {
|
|
108
|
-
"@reactunity/
|
|
109
|
-
"
|
|
110
|
-
"
|
|
109
|
+
"@reactunity/previewer": "*",
|
|
110
|
+
"@reactunity/renderer": "^0.12.0",
|
|
111
|
+
"react": "^18.0.0",
|
|
112
|
+
"typescript": "^4.7.3"
|
|
111
113
|
},
|
|
112
114
|
"peerDependenciesMeta": {
|
|
115
|
+
"@reactunity/previewer": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
113
118
|
"typescript": {
|
|
114
119
|
"optional": true
|
|
115
120
|
}
|
|
116
|
-
}
|
|
117
|
-
"bundledDependencies": [
|
|
118
|
-
"@typescript-eslint/eslint-plugin",
|
|
119
|
-
"eslint-plugin-import",
|
|
120
|
-
"eslint-plugin-jest",
|
|
121
|
-
"eslint-plugin-react",
|
|
122
|
-
"eslint-plugin-react-hooks",
|
|
123
|
-
"eslint-plugin-testing-library"
|
|
124
|
-
]
|
|
121
|
+
}
|
|
125
122
|
}
|
package/scripts/build.js
CHANGED
|
@@ -31,14 +31,13 @@ const configFactory = require('../config/webpack.config');
|
|
|
31
31
|
const paths = require('../config/paths');
|
|
32
32
|
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
33
33
|
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
34
|
-
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
|
35
34
|
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
36
35
|
const printBuildError = require('react-dev-utils/printBuildError');
|
|
36
|
+
const { cleanBuildDirectory } = require('./utils/cleanBuildDirectory');
|
|
37
37
|
|
|
38
38
|
const measureFileSizesBeforeBuild =
|
|
39
39
|
FileSizeReporter.measureFileSizesBeforeBuild;
|
|
40
40
|
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
41
|
-
const useYarn = fs.existsSync(paths.yarnLockFile);
|
|
42
41
|
|
|
43
42
|
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
44
43
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
@@ -67,9 +66,7 @@ checkBrowsers(paths.appPath, isInteractive)
|
|
|
67
66
|
return measureFileSizesBeforeBuild(paths.appBuild);
|
|
68
67
|
})
|
|
69
68
|
.then(previousFileSizes => {
|
|
70
|
-
|
|
71
|
-
// if you're in it, you don't end up in Trash
|
|
72
|
-
fs.emptyDirSync(paths.appBuild);
|
|
69
|
+
cleanBuildDirectory();
|
|
73
70
|
// Merge with the public folder
|
|
74
71
|
copyPublicFolder();
|
|
75
72
|
// Start the webpack build
|
|
@@ -104,17 +101,8 @@ checkBrowsers(paths.appPath, isInteractive)
|
|
|
104
101
|
);
|
|
105
102
|
console.log();
|
|
106
103
|
|
|
107
|
-
const appPackage = require(paths.appPackageJson);
|
|
108
|
-
const publicUrl = paths.publicUrlOrPath;
|
|
109
|
-
const publicPath = config.output.publicPath;
|
|
110
104
|
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
|
111
|
-
|
|
112
|
-
appPackage,
|
|
113
|
-
publicUrl,
|
|
114
|
-
publicPath,
|
|
115
|
-
buildFolder,
|
|
116
|
-
useYarn
|
|
117
|
-
);
|
|
105
|
+
console.log(`The ${chalk.blue(buildFolder)} folder is ready to be used in ReactUnity.`);
|
|
118
106
|
},
|
|
119
107
|
err => {
|
|
120
108
|
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
package/scripts/clean.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @remove-on-eject-begin
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
// @remove-on-eject-end
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
12
|
+
process.env.BABEL_ENV = 'production';
|
|
13
|
+
process.env.NODE_ENV = 'production';
|
|
14
|
+
|
|
15
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
16
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
17
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
18
|
+
process.on('unhandledRejection', err => {
|
|
19
|
+
throw err;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Ensure environment variables are read.
|
|
23
|
+
require('../config/env');
|
|
24
|
+
|
|
25
|
+
const path = require('path');
|
|
26
|
+
const chalk = require('react-dev-utils/chalk');
|
|
27
|
+
const paths = require('../config/paths');
|
|
28
|
+
const { cleanBuildDirectory } = require('./utils/cleanBuildDirectory');
|
|
29
|
+
|
|
30
|
+
Promise.resolve().then(() => {
|
|
31
|
+
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
|
32
|
+
console.log(`Cleaning build directory at ${chalk.blue(buildFolder)}`);
|
|
33
|
+
cleanBuildDirectory();
|
|
34
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @remove-on-eject-begin
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
// @remove-on-eject-end
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const fs = require('fs-extra');
|
|
13
|
+
const paths = require('../../config/paths');
|
|
14
|
+
|
|
15
|
+
function cleanBuildDirectory() {
|
|
16
|
+
try {
|
|
17
|
+
if (fs.existsSync(paths.appManifest)) {
|
|
18
|
+
// Clean only the files inside the asset-manifest so that we avoid cleaning files belonging to user
|
|
19
|
+
const manifestContent = fs.readFileSync(paths.appManifest, 'utf8');
|
|
20
|
+
const manifest = JSON.parse(manifestContent);
|
|
21
|
+
|
|
22
|
+
const keys = Object.keys(manifest.files);
|
|
23
|
+
|
|
24
|
+
for (const key of keys) {
|
|
25
|
+
const file = manifest.files[key];
|
|
26
|
+
const filePath = path.join(paths.appBuild, file);
|
|
27
|
+
const metaFile = filePath + '.meta';
|
|
28
|
+
|
|
29
|
+
fs.removeSync(filePath);
|
|
30
|
+
fs.removeSync(metaFile);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const manifestMeta = paths.appManifest + '.meta';
|
|
34
|
+
fs.removeSync(paths.appManifest);
|
|
35
|
+
fs.removeSync(manifestMeta);
|
|
36
|
+
|
|
37
|
+
cleanEmptyFoldersRecursively(null, paths.appBuild, true);
|
|
38
|
+
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
} catch (err) { }
|
|
42
|
+
|
|
43
|
+
console.log('Skipped clearing output directory because asset manifest was not found. Please clean the output directory manually if necessary.');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function cleanEmptyFoldersRecursively(parent, folder, skipFirst) {
|
|
48
|
+
if (!fs.existsSync(folder)) return;
|
|
49
|
+
var isDir = fs.statSync(folder).isDirectory();
|
|
50
|
+
if (!isDir) return;
|
|
51
|
+
|
|
52
|
+
var files = fs.readdirSync(folder);
|
|
53
|
+
if (files.length > 0) {
|
|
54
|
+
files.forEach(function (file) {
|
|
55
|
+
var fullPath = path.join(folder, file);
|
|
56
|
+
cleanEmptyFoldersRecursively(folder, fullPath, false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// re-evaluate files; after deleting subfolder
|
|
60
|
+
// we may have parent folder empty now
|
|
61
|
+
files = fs.readdirSync(folder);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!skipFirst && files.length == 0) {
|
|
65
|
+
fs.rmdirSync(folder);
|
|
66
|
+
|
|
67
|
+
if (parent) {
|
|
68
|
+
const folderName = path.basename(folder);
|
|
69
|
+
const dirMeta = path.join(parent, folderName + '.meta');
|
|
70
|
+
fs.removeSync(dirMeta);
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports.cleanBuildDirectory = cleanBuildDirectory;
|
|
Binary file
|