<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CLI upload main.js file size limited when building with react and threejs in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/518320#M25847</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/250152"&gt;@AMMehta&lt;/a&gt;&amp;nbsp;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&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import * as x from 'lib';&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and instead do:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import { each, func, you, need } from 'lib';&lt;/LI-CODE&gt;&lt;P&gt;this will allow bundlers such as Webpack to properly Tree Shake your dependencies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;</description>
    <pubDate>Fri, 29 Oct 2021 19:58:42 GMT</pubDate>
    <dc:creator>kierana</dc:creator>
    <dc:date>2021-10-29T19:58:42Z</dc:date>
    <item>
      <title>CLI upload main.js file size limited when building with react and threejs</title>
      <link>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/518258#M25844</link>
      <description>&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[ERROR] Error validating template.
[ERROR] line 0: Coded files must be smaller than 1.5 MiB&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to upload the file directly to the design manager but was given the same error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried to create a main.js file and past the code into it but was give the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;1. Error:Coded file buffer must be smaller than 2.0 MiB&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 18:02:16 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/518258#M25844</guid>
      <dc:creator>AMMehta</dc:creator>
      <dc:date>2021-10-29T18:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: CLI upload main.js file size limited when building with react and threejs</title>
      <link>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/518292#M25845</link>
      <description>&lt;P&gt;Did you know that &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/138846"&gt;@kierana&lt;/a&gt; is one of the smartest fellows I know?&amp;nbsp; If anyone has a workaround, it would be him&lt;/P&gt;
&lt;P&gt;(no pressure, &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/138846"&gt;@kierana&lt;/a&gt; )&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 19:02:09 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/518292#M25845</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-10-29T19:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: CLI upload main.js file size limited when building with react and threejs</title>
      <link>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/518316#M25846</link>
      <description>&lt;P&gt;A work around or a way to reduce my file size works.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 19:51:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/518316#M25846</guid>
      <dc:creator>AMMehta</dc:creator>
      <dc:date>2021-10-29T19:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: CLI upload main.js file size limited when building with react and threejs</title>
      <link>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/518320#M25847</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/250152"&gt;@AMMehta&lt;/a&gt;&amp;nbsp;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&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import * as x from 'lib';&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and instead do:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import { each, func, you, need } from 'lib';&lt;/LI-CODE&gt;&lt;P&gt;this will allow bundlers such as Webpack to properly Tree Shake your dependencies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 19:58:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/518320#M25847</guid>
      <dc:creator>kierana</dc:creator>
      <dc:date>2021-10-29T19:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: CLI upload main.js file size limited when building with react and threejs</title>
      <link>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/523233#M26037</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in package.json&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;"start": "webpack serve --open --config webpack.dev.js", // local
"start-hs": "webpack --watch --env autoupload --config webpack.prod.js" // HS&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;webpack.common.js&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const path = require('path');

module.exports = {
  entry: {
    main: './src/index.js',
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
        },
      },
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif)$/i,
        type: 'asset/resource',
      },
    ],
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
  },
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist'),
    clean: true,
    publicPath: '/',
  },
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;webpack.dev.js&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const webpack = require('webpack');

module.exports = merge(common, {
  mode: 'development',
  target: 'web',
  // devtool: 'inline-source-map',
  devServer: {
    contentBase: path.join(__dirname, 'dist'),
    writeToDisk: true,
  },
  plugins: [
    new webpack.ProvidePlugin({
      process: 'process/browser',
    }),
    new CopyWebpackPlugin([{ from: 'src/images', to: 'images' }]),
    new HtmlWebpackPlugin({
      title: 'Dev',
      template: path.resolve(__dirname, 'src/public/index.html'),
      inject: true,
    }),
  ],
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;webpack.prod.js&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const CopyWebpackPlugin = require('copy-webpack-plugin');
const HubSpotAutoUploadPlugin = require('@hubspot/webpack-cms-plugins/HubSpotAutoUploadPlugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const common = require('./webpack.common.js');
const { merge } = require('webpack-merge');
const webpack = require('webpack');

const hubspotConfig = ({ portal, autoupload } = {}) =&amp;gt; {
  return merge(common, {
    mode: 'production',
    plugins: [
      new webpack.ProvidePlugin({
        process: 'process/browser',
      }),
      new MiniCssExtractPlugin({
        filename: '[name].css',
      }),
      new HubSpotAutoUploadPlugin({
        portal,
        autoupload,
        src: 'dist',
        dest: 'avidly-react-app',
      }),
      new CopyWebpackPlugin([
        { from: 'src/images', to: 'images' },
        {
          from: 'src/modules',
          to: 'modules',
        },
      ]),
    ],
  });
};

module.exports = [hubspotConfig];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers, JJ&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 10:20:27 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/523233#M26037</guid>
      <dc:creator>jjtoikka</dc:creator>
      <dc:date>2021-11-10T10:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: CLI upload main.js file size limited when building with react and threejs</title>
      <link>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/532025#M26287</link>
      <description>&lt;DIV&gt;
&lt;P&gt;Try compressing your files into .min.js files&amp;nbsp;&lt;A href="https://www.toptal.com/developers/javascript-minifier/" target="_blank" rel="nofollow noopener noreferrer"&gt;with this&lt;/A&gt;&amp;nbsp;if you are done editing them.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 29 Nov 2021 16:29:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/532025#M26287</guid>
      <dc:creator>ameen_khan15</dc:creator>
      <dc:date>2021-11-29T16:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: CLI upload main.js file size limited when building with react and threejs</title>
      <link>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/586847#M27626</link>
      <description>&lt;P&gt;Another solution is use &lt;A href="https://v4.webpack.js.org/plugins/split-chunks-plugin/" target="_blank" rel="noopener"&gt;optimization.splitChunks option&lt;/A&gt; to devide one large file into several smaller files.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 13:23:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/586847#M27626</guid>
      <dc:creator>assi</dc:creator>
      <dc:date>2022-03-02T13:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: CLI upload main.js file size limited when building with react and threejs</title>
      <link>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/762519#M33051</link>
      <description>&lt;P&gt;As mentioned already, minimizing main.js can temporary work around this issue.&lt;/P&gt;&lt;P&gt;Easiest way I found to do this when still developing is by adding to the webpack the following object:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;optimization: {
  minimize: true,
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This has been so far just fine for me and as long as the compressed file won't exceed the size limit it should be ok.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However looking at splitting the main.js file into several smaller files is the stable solution you want to look for.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 10:27:16 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/CLI-upload-main-js-file-size-limited-when-building-with-react/m-p/762519#M33051</guid>
      <dc:creator>Stefaninoo</dc:creator>
      <dc:date>2023-03-01T10:27:16Z</dc:date>
    </item>
  </channel>
</rss>

