CLI upload main.js file size limited when building with react and threejs
SOLVE
Is there a way around the file size limitation. I am building a react module with three js (using the cms-react-boilerplate). The project builds fine but it cant uplaod the main.js file as it is 2.1MiB. it gives me the following error:
[ERROR] Error validating template.
[ERROR] line 0: Coded files must be smaller than 1.5 MiB
I tried to upload the file directly to the design manager but was given the same error.
I also tried to create a main.js file and past the code into it but was give the following error:
1. Error:Coded file buffer must be smaller than 2.0 MiB
CLI upload main.js file size limited when building with react and threejs
SOLVE
Hey @AMMehta that's a big file! I'd recommend enabling code splitting. If not, you're going to need to use a different host for the Javascript files. Additionally - make sure you're correctly including only what you need. Avoid
import * as x from 'lib';
and instead do:
import { each, func, you, need } from 'lib';
this will allow bundlers such as Webpack to properly Tree Shake your dependencies.
CLI upload main.js file size limited when building with react and threejs
SOLVE
Hi,
I had the same issue, so I made improvements to the Webpack config files. Created one for dev and one for production. Got the file size down to 500kt. I'm using the built npm library, so the boilerplate build must add a lot of extra stuff there. The configs in the HS boilerplate repo is not optimized well. Added also local development environment, so you don't have to push to HS all the time, instead develop local and in the end push to HS. This is a Typescript example.
CLI upload main.js file size limited when building with react and threejs
SOLVE
Hi,
I had the same issue, so I made improvements to the Webpack config files. Created one for dev and one for production. Got the file size down to 500kt. I'm using the built npm library, so the boilerplate build must add a lot of extra stuff there. The configs in the HS boilerplate repo is not optimized well. Added also local development environment, so you don't have to push to HS all the time, instead develop local and in the end push to HS. This is a Typescript example.
CLI upload main.js file size limited when building with react and threejs
SOLVE
Hey @AMMehta that's a big file! I'd recommend enabling code splitting. If not, you're going to need to use a different host for the Javascript files. Additionally - make sure you're correctly including only what you need. Avoid
import * as x from 'lib';
and instead do:
import { each, func, you, need } from 'lib';
this will allow bundlers such as Webpack to properly Tree Shake your dependencies.