Production build assumes existence of `inc/` directory within project root
Closed this issue · 5 comments
What happened?
When running a build, Build Tools assumes the existence of an inc/
directory in the project root. If the directory doesn't exist, a raw error is thrown by Node.js as Build Tools attempts to write to the file inc/asset-settings.php
.
Ideally, Build Tools would attempt create the directory (if it doesn't exist); alternatively, a more user-friendly error message could be thrown.
The command I am running to reproduce this is
build-tools build --production --once
My directory structure looks like the following:
project/
- dist/
- src/
- package.json
- webpack.config.js
- yarn.lock
Which environments are you experiencing the issue on?
CLI (macOS, Windows, etc)
Relevant log output
yarn run v1.22.19
warning package.json: No license field
$ build-tools build --production --once
Compiling single project in production mode.
Processing the following projects:
* [sample-project/package.json]
⠼ Compiling...Error: ENOENT: no such file or directory, open '/Users/jon/Code/temp/sample-project/inc/asset-settings.php'
at Object.openSync (node:fs:601:3)
at Object.writeFileSync (node:fs:2249:35)
at /Users/jon/Code/temp/sample-project/node_modules/@bigbite/build-tools/src/commands/build/plugins/custom/template-generator/index.js:28:12
at Array.forEach (<anonymous>)
at TemplateGenerator.createTemplates (/Users/jon/Code/temp/sample-project/node_modules/@bigbite/build-tools/src/commands/build/plugins/custom/template-generator/index.js:18:20)
at Hook.eval [as callAsync] (eval at create (/Users/jon/Code/temp/sample-project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/jon/Code/temp/sample-project/node_modules/tapable/lib/Hook.js:18:14)
at /Users/jon/Code/temp/sample-project/node_modules/webpack/lib/Compiler.js:882:27
at /Users/jon/Code/temp/sample-project/node_modules/neo-async/async.js:2818:7
at done (/Users/jon/Code/temp/sample-project/node_modules/neo-async/async.js:3522:9)
at Hook.eval [as callAsync] (eval at create (/Users/jon/Code/temp/sample-project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at /Users/jon/Code/temp/sample-project/node_modules/webpack/lib/Compiler.js:736:33
at /Users/jon/Code/temp/sample-project/node_modules/graceful-fs/graceful-fs.js:143:16
at /Users/jon/Code/temp/sample-project/node_modules/graceful-fs/graceful-fs.js:61:14
at FSReqCallback.oncomplete (node:fs:198:23) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/Users/jon/Code/temp/sample-project/inc/asset-settings.php'
}
1 asset
chunk (runtime: frontend) frontend-ffc666a0.js (frontend) 208 KiB [entry] [rendered]
8 modules
webpack 5.88.2 compiled successfully in 1993 ms
✔ Build complete.
✨ Done in 3.01s.
@jonmcp Which version of Build Tools are you running here?
I was actually running on #hotfix/handle-overwritten-externals
, but experience the same output on v1.2.2
@jonmcp I've done some testing and the problem isn't the missing asset-settings.php
, it's a missing inc/
directory. If that directory exists, then the asset-settings.php
file is created as expected.
I've found the following file and directory structures work as expected:
✅ Working:
inc/
src/
- entrypoints/
- frontend.js
✅ Working:
inc/
- asset_settings.php
src/
- entrypoints/
- frontend.js
❌ Failing:
src/
- entrypoints/
- frontend.js
Tested by using the example-site
and removing the inc
directories in test-client-plugin
and test-plugin
. The following command run:
cd example-site
node ../src/cli.js build --once test-client-plugin,test-plugin
Ah; thanks for that, and apologies for not attempting that during my testing prior to creating this issue.
I can confirm that adding an empty inc
directory resolves the error.
Would you like me to update the issue title and description for clarity?
@jonmcp Yeah that would be great thank you.