I am creating and assembling a web solution via react-scripts build.
I am creating a fully working instance of the site.
When building (dfx deploy), a lot of errors are thrown. It looks like dfx wants to build via webpack Question:
How to build a website into a wasm file if I don’t use webpack, but let’s say I build it separately via react-scripts build.?
I did a similar thing in dfx version 0.12.1, I managed to build the web in wasm. I poured it into a web canister. I also have a demo version that works fine through the created via (dfx new) But the peculiarity is that I have an application react, with .ts
@NathanosDev just added the ability to run custom build commands for asset canisters: PR. If you run the latest dfx beta release (0.14.1-beta.1) you should already have access to that feature
Yes, there are errors when building the project.
Console error:
dfx deploy
Building frontend...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
Failed to build all canisters.
Failed while trying to build all canisters.
The post-build step failed for canister 'bd3sg-teaaa-aaaaa-qaaba-cai' (web_admin) with an embedded error: Failed to build frontend for network 'local'.: The command '"npm" "run" "build"' failed with exit status 'exit status: 1'.
Stdout:
> rbac_frontend@0.2.0 prebuild
> dfx generate
> rbac_frontend@0.2.0 build
> webpack
dfx deploy
Deploying all canisters.
All canisters have already been created.
Building canisters...
Building frontend...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
Failed to build all canisters.
Failed while trying to build all canisters.
The post-build step failed for canister 'bd3sg-teaaa-aaaaa-qaaba-cai' (web_admin) with an embedded error: Failed to build frontend for network 'local'.: The command '"npm" "run" "build"' failed with exit status 'exit status: 1'.
Stdout:
> rbac@0.2.0 prebuild
> dfx generate
> rbac@0.2.0 build
> webpack
asset index.html 2.56 KiB [compared for emit]
asset index.js 99 bytes [compared for emit] (name: index)
ERROR in index
Module not found: Error: Can't resolve 'ts-loader' in '/home/fury02/Projects_4/rbac'
ERROR in unable to locate '/home/fury02/Projects_4/rbac/src/public/assets' glob
ERROR in Error: Child compilation failed:
Module not found: Error: Can't resolve 'ts-loader' in '/home/fury02/Projects_4 /rbac'
ModuleNotFoundError: Module not found: Error: Can't resolve 'ts-loader' in '/h ome/fury02/Projects_4/rbac'
at /home/fury02/Projects_4/rbac/node_modules/webpack/lib/Compilation.js:20 16:28
at /home/fury02/Projects_4/rbac/node_modules/webpack/lib/NormalModuleFacto ry.js:817:13
at eval (eval at create (/home/fury02/Projects_4/rbac/node_modules/tapable /lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
at /home/fury02/Projects_4/rbac/node_modules/webpack/lib/NormalModuleFacto ry.js:275:22
at eval (eval at create (/home/fury02/Projects_4/rbac/node_modules/tapable /lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
at /home/fury02/Projects_4/rbac/node_modules/webpack/lib/NormalModuleFacto ry.js:560:15
at /home/fury02/Projects_4/rbac/node_modules/webpack/lib/NormalModuleFacto ry.js:118:11
at /home/fury02/Projects_4/rbac/node_modules/webpack/lib/NormalModuleFacto ry.js:631:8
at /home/fury02/Projects_4/rbac/node_modules/neo-async/async.js:2830:7
at done (/home/fury02/Projects_4/rbac/node_modules/neo-async/async.js:2925 :13)
- Compilation.js:2016
[rbac]/[webpack]/lib/Compilation.js:2016:28
- NormalModuleFactory.js:817
[rbac]/[webpack]/lib/NormalModuleFactory.js:817:13
- NormalModuleFactory.js:275
[rbac]/[webpack]/lib/NormalModuleFactory.js:275:22
- NormalModuleFactory.js:560
[rbac]/[webpack]/lib/NormalModuleFactory.js:560:15
- NormalModuleFactory.js:118
[rbac]/[webpack]/lib/NormalModuleFactory.js:118:11
- NormalModuleFactory.js:631
[rbac]/[webpack]/lib/NormalModuleFactory.js:631:8
- async.js:2830
[rbac]/[neo-async]/async.js:2830:7
- async.js:2925 done
[rbac]/[neo-async]/async.js:2925:13
- child-compiler.js:169
[rbac]/[html-webpack-plugin]/lib/child-compiler.js:169:18
- Compiler.js:551 finalCallback
[rbac]/[webpack]/lib/Compiler.js:551:5
- Compiler.js:577
[rbac]/[webpack]/lib/Compiler.js:577:11
- Compiler.js:1199
[rbac]/[webpack]/lib/Compiler.js:1199:17
- Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
[rbac]/[tapable]/lib/Hook.js:18:14
- Compiler.js:1195
[rbac]/[webpack]/lib/Compiler.js:1195:33
- Compilation.js:2787 finalCallback
[rbac]/[webpack]/lib/Compilation.js:2787:11
- Compilation.js:3092
[rbac]/[webpack]/lib/Compilation.js:3092:11
1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
1 error has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.81.0 compiled with 4 errors in 194 ms
Stderr:
Building canisters before generate for Motoko
Generating type declarations for canister web_admin:
src/declarations/web_admin/web_admin.did.d.ts
src/declarations/web_admin/web_admin.did.js
src/declarations/web_admin/web_admin.did
Generating type declarations for canister rbac:
src/declarations/rbac/rbac.did.d.ts
src/declarations/rbac/rbac.did.js
src/declarations/rbac/rbac.did
nex steps:
copy files .dfx/local/canisters in .dfx/ic/canisters
dfx canister --network ic install web_admin --mode reinstall
not errors
Thanks for sharing your project. So it seems that support for custom build commands for asset canisters has not been included in the 0.14.1 release of DFX, even though the release notes include it. But you can fix your project without using this custom build command.
One issue on your project comes from having multiple package.json files. The package.json at the root of your project is the one that DFX is using to build your project, but the correct build configuration for your project is in src/web_admin/package.json.
I’m seeing an error from the frontend. It seems that you’re pointing the host directly at icp0.io which is throwing a cors error.
I don’t think that behavior is correct, and I’ll raise it with the boundary node team, but in the meantime, I recommend setting host to undefined or pointing it to https://icp-api.io
Hi!
I’m rebuilding from CRA (it’s outdated) to Vite - React. So far everything is correct out of the box. There is one more detail in the Chrome browser error
Failed to create a secure connection with the Internet Computer.
Please try clearing your browser cache and refreshing the page to try again.
Based on this error, it looks like there’s an issue with the boundary nodes failing to handle the status call during fetchRootKey. Either that, or the serviceworker is failing to catch it, but either way