search

Home  >  Q&A  >  body text

Skip larger chunks to run "Npm run build"

<p>I encountered this problem while trying to run "<code>npm run build</code>"</p> <pre class="brush:php;toolbar:false;">(!) Some blocks are larger than 500 KiB after minification. Please consider: - Use dynamic import() to code split your application - Use build.rollupOptions.output.manualChunks to improve chunk splitting: https://rollupjs.org/guide/en/#outputmanualchunks - Adjust the chunk size limit for this warning via build.chunkSizeWarningLimit. </pre> <p><br /></p>
P粉381463780P粉381463780584 days ago764

reply all(2)I'll reply

  • P粉343408929

    P粉3434089292023-08-25 10:21:09

    EDIT: Here is a workaround, just hide the warning

    Add command in vite.config.js

    1

    2

    3

    build: {

        chunkSizeWarningLimit: 1600,

      },

    Complete code

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    // https://vitejs.dev/config/

    export default defineConfig({

      base: "/Stakepool-Frontend/",

      plugins: [vue()],

      resolve: {

        alias: {

          "~": path.resolve(__dirname, "node_modules"),

          "@": path.resolve(__dirname, "src"),

        },

      },

      build: {

        chunkSizeWarningLimit: 1600,

      },

    });

    reply
    0
  • P粉153503989

    P粉1535039892023-08-25 00:02:56

    If you don't want to increase chunkSizeWarningLimit and are more concerned with solving the actual size problem, try the following solutions:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    export default defineConfig({

    ....

    build: {

            rollupOptions: {

                output:{

                    manualChunks(id) {

                        if (id.includes('node_modules')) {

                            return id.toString().split('node_modules/')[1].split('/')[0].toString();

                        }

                    }

                }

            }

        }

    });

    reply
    0
  • Cancelreply