• Do not create multi-accounts, you will be blocked! For more information about rules, limits, and more, visit the, Help page.
    Found a dead link? report button!
    Make this beautiful and clickable botton with link

Single input field of rollupOptions in vite causing 404 block

Points 18
Solutions 0
BrilliantBrilliant is verified member.
A 404 error when using rollupOptions in Vite typically means that the Rollup configuration is misconfigured, resulting in incorrect paths being generated for assets or modules. Let’s troubleshoot and resolve this issue.


---

Possible Causes

1. Incorrect output.entryFileNames or output.assetFileNames in rollupOptions: Customizing the output filenames improperly can result in files not being found or served.


2. Missing assets during build: If assets are moved or renamed incorrectly, the browser may not find them.


3. Incorrect paths in your code: The build process might produce paths that don’t match the structure of the output files.


4. Improper Vite base configuration: If the base option in Vite is not set correctly, it can cause 404 errors.




---

Fixes for rollupOptions

Here’s how you can configure the rollupOptions properly in vite.config.js:

Example vite.config.js:

JavaScript:
import { defineConfig } from 'vite';



export default defineConfig({

  build: {

    rollupOptions: {

      output: {

        // Customize the output filenames for JavaScript files

        entryFileNames: 'assets/[name].[hash].js',

        chunkFileNames: 'assets/[name].[hash].js',

        assetFileNames: 'assets/[name].[hash].[ext]', // For other assets like images, CSS, etc.

      }

    },

    // Ensure correct base path if the app is not deployed at root

    base: '/',

  }

});


---

Troubleshooting Steps

1. Verify Output Paths: Ensure that the custom file names in rollupOptions.output match your file structure. For instance:

Use assets/[name].[hash].js for JavaScript files.

Use assets/[name].[hash].[ext] for other assets.



2. Check the base Option: If your app is deployed to a subdirectory (e.g., /subdir), set the base option accordingly in vite.config.js:

JavaScript:
base: '/subdir/',

3. Check the Dev Server: During development (vite dev), Vite serves files from memory, not the output directory. Make sure there are no absolute paths pointing to dist/ or other incorrect directories.


4. Clear Browser Cache: A cached version of your application may not match the current build output.


5. Inspect Generated Files: After building the app, inspect the dist/ directory. Confirm that the files match the paths being requested by the browser.


6. Analyze 404 Errors in Network Tab: Use the browser’s developer tools to check which files are causing the 404 errors. Compare the paths being requested with the actual paths in dist/.




---

Example with base Option for Subdirectory Deployment

If you’re deploying to a subdirectory (e.g., https://example.com/app/), use:

JavaScript:
export default defineConfig({

  base: '/app/',

  build: {

    rollupOptions: {

      output: {

        entryFileNames: 'assets/[name].[hash].js',

        chunkFileNames: 'assets/[name].[hash].js',

        assetFileNames: 'assets/[name].[hash].[ext]',

      }

    }

  }

});


---

Debugging Commands

Run the following commands to debug:

1. Preview the Build:

JavaScript:
npm run build

npm run preview

This serves the build locally and helps verify if the issue persists.


2. Analyze the Build Output:

JavaScript:
vite build --mode development --debug



---

Final Checklist

Custom Rollup Output: Ensure rollupOptions.output generates valid paths.

Base Path: Match the deployment base path in vite.config.js.

Correct Imports: Use relative imports (./) for files within the app.

Static Assets: Place static assets in the public/ folder for correct serving.
 
Каталог можно частично настроить на свой вкус, выводя товары списком с изображениями или без, а так-же стандартной сеткой https://акваторг24.рф/armatura-izmeritelnaya-i-komplektuyuschie/termometry-i-termomanometry/termomanometr-mvi-aksialnyy-diametr-korpusa-mm-d80-6-bar-0-6-mpa-ot-0c-do-120c-1-2-art-atm-80-12006-04/

Для быстрого и удобного поиска товаров ассортимент в каталоге разбит по категориям, имеется поисковая строка и фильтр характеристик оборудования https://акваторг24.рф/zapornaya-radiatornaya-kotelnaya-armatura/kran-amerikanka-uglovoy-nikelirovannyy-tim-1-g-sh-art-de1237x/
Каждая товарная позиция дополнена подробным описанием, техническими данными и стоимостью https://акваторг24.рф/vodosnabzhenie-vodonagrevateli-filtry/gidroakkumulyator-dlya-sistem-holodnogo-vodosnabzheniya-tim-80l-art-hc-80l/

На сайте отдельным разделом вынесены отзывы покупателей магазина Santehmoll https://акваторг24.рф/kollektory-shkafy-komplektuyuschie/komplektuyuschie-dlya-kollektorov/konechnyy-element-dlya-kollektora-s-avtomaticheskim-vozduhootvodchikom-mvi-art-mc-201-06/
Приятно, что негативные отзывы о товаре не удаляются администрацией магазина https://акваторг24.рф/fitingi-dlya-trub/fitingi-dlya-gofrirovannyh-trub-iz-nerzhaveyuschey-stali-zeissler/mufta-reduktsionnaya-nikelirovannaya-20-15-art-zti-613-002015n/

Интернет-магазин Дюйм специализируется на продаже инженерной сантехники оптом и в розницу и является одним из лидеров на рынке сантехники в России https://акваторг24.рф/fitingi-dlya-trub/aksialnye-fitingi/aksialnaya-mufta-mvi-ravnostoronnyaya-20-art-sf-422-05/
Философия данной компании - обеспечить все потребности клиента во время монтажа системы отопления, канализации и водоснабжения https://акваторг24.рф/protivopozharnye-truby-i-fitingi/protivopozharnye-truby-green/polipropilenovaya-truba-dlya-pozharotusheniya-pp-r-gf-sdr6-o90x4-2-v-otrezkah-po-4-metra-slt-aqua/
В каталоге представлен широкий ассортимент продукции различной ценовой категории https://акваторг24.рф/konvektora-itermic/
Следует отметить, что на складах компании представлены 9000 различных наименований инженерной сантехники, а еще 7000 товаров можно получить под заказ https://акваторг24.рф/zapornaya-radiatornaya-kotelnaya-armatura/gruppa-bezopasnosti-boylera-52-3-4-do-20-kvt-tim-art-jh-2013-7/
Обширный выбор продукции возможен благодаря тому, что складские помещения занимают более 27 000 м2 https://акваторг24.рф/zapornaya-radiatornaya-kotelnaya-armatura/kollektor-iz-nerzhaveyuschey-stali-dlya-otopleniya-v-sbore-mvi-na-10-vyh-art-ms-410-06/
Они расположены в Московской области https://акваторг24.рф/truby/truby-iz-sshitogo-polietilena-pex/truba-iz-sshitogo-polietilena-pex-b-o16h2-0-mm-tim-buhta-100-m-stabili-art-tpap-1620-100-stabil/
Это обеспечивает большую мобильность в оформлении и доставке заказа клиенту https://акваторг24.рф/baki-membrannye/baki-rasshiritelnye-dlya-otopleniya/rasshiritelnyy-bak-dlya-sistem-otopleniya-tim-vertikalnyy-2-l-art-vc-2ld/

Традиционно люди привыкли покупать сантехнику в офлайн-магазинах, где ее можно увидеть воочию, изучить, подержать в руках, даже попробовать в действии https://акваторг24.рф/product/vysota-v-mm/35/
Это надежно, ведь риск приобрести сводится к минимуму https://акваторг24.рф/zapornaya-radiatornaya-kotelnaya-armatura/termogolovka-zhidkostnaya-tim-m30-h-1-5-art-th-d-0101/
Однако, в последнее время интернет-магазины сантехники в Москве с выставочными залами становятся все более популярной альтернативой и отзывы по большей части доказывают достаточно лояльное отношение покупателей https://акваторг24.рф/armatura-zapornaya/krany-sharovye-dlya-santehnicheskih-priborov/kran-ventil-uglovoy-dlya-podklyucheniya-santehnicheskih-priborov-mvi-hromirovannyy-3-4-nar-nar-art-bv-460-05/

Мы рады ответить на все ваши вопросы https://акваторг24.рф/protivopozharnye-truby-i-fitingi/protivopozharnye-fitingi-red/burt-pod-flanets-ppr-o63-slt-blockfire/
 

Be clear and specific: Instead of saying "it doesn't work" , provide details, logs, screenshots, or a description of the problem.

Back