Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-pages app on build, ignores files other than index.html #9201

Closed
7 tasks done
sidneifjr opened this issue Jul 18, 2022 · 2 comments
Closed
7 tasks done

Multi-pages app on build, ignores files other than index.html #9201

sidneifjr opened this issue Jul 18, 2022 · 2 comments
Labels
invalid This doesn't seem right

Comments

@sidneifjr
Copy link

sidneifjr commented Jul 18, 2022

I'm building an multi-page app (HTML, CSS and TypeScript) that, thus far, works almost flawlessly on development. Each of my components have their own folder (with a index.html, styles.scss and main.ts). My intent is that each index.html file shows up together in the dist folder, when building for production.

On build, however, only the root index.html is compiled; all my other assets and components (and their corresponding nested 'index.html' files) are ignored. My vite.config.js is as follows:

`

import { fileURLToPath } from 'url'
import { defineConfig } from 'vite'

export default defineConfig({
  build: {
    outDir: 'dist',

    rollupOptions: {
      input: {
        index: fileURLToPath(new URL('index.html', import.meta.url)),
        webdoor: fileURLToPath(new URL('src/componentes/Webdoor/index.html', import.meta.url)),
        accordion: fileURLToPath(new URL('src/componentes/Accordion/index.html', import.meta.url))
      },
    }
  },
})

`

I've already checked the following issues, but none managed to solve it:

#7891
#2656 (comment)
#2958
#7275

Reproduction

https://stackblitz.com/edit/vitejs-vite-clevpb?file=dist/index.html

System Info

System:
    OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
    Memory: 10.79 GB / 12.43 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 16.16.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - /usr/local/bin/npm
  npmPackages:
    vite: ^3.0.0 => 3.0.0

Used Package Manager

yarn

Logs

Click to expand!
yarn run v1.22.19
$ vite build --debug
  vite:config bundled config file loaded in 164.44ms +0ms
  vite:config using resolved config: {
  vite:config   build: {
  vite:config     target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: { build: [Object] },
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     reportCompressedSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
  vite:config   },
  vite:config   optimizeDeps: {
  vite:config     disabled: 'build',
  vite:config     force: undefined,
  vite:config     esbuildOptions: { preserveSymlinks: undefined }
  vite:config   },
  vite:config   configFile: '/app/vite.config.js',
  vite:config   configFileDependencies: [ '/app/vite.config.js' ],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     optimizeDeps: { force: undefined },
  vite:config     build: {}
  vite:config   },
  vite:config   root: '/app',
  vite:config   base: '/',
  vite:config   resolve: { alias: [ [Object], [Object] ] },
  vite:config   publicDir: '/app/public',
  vite:config   cacheDir: '/app/node_modules/.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   ssr: {
  vite:config     format: 'esm',
  vite:config     target: 'node',
  vite:config     optimizeDeps: { disabled: true, esbuildOptions: [Object] }
  vite:config   },
  vite:config   isWorker: false,
  vite:config   mainConfig: null,
  vite:config   isProduction: true,
  vite:config   plugins: [
  vite:config     'vite:build-metadata',
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html-inline-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm-helper',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:wasm-fallback',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:watch-package-data',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'vite:asset-import-meta-url',
  vite:config     'vite:dynamic-import-vars',
  vite:config     'vite:import-glob',
  vite:config     'vite:build-import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:reporter',
  vite:config     'vite:load-fallback'
  vite:config   ],
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     middlewareMode: false,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] }
  vite:config   },
  vite:config   preview: {
  vite:config     port: undefined,
  vite:config     strictPort: undefined,
  vite:config     host: undefined,
  vite:config     https: undefined,
  vite:config     open: undefined,
  vite:config     proxy: undefined,
  vite:config     cors: undefined,
  vite:config     headers: undefined
  vite:config   },
  vite:config   env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   packageCache: Map(0) { set: [Function (anonymous)] },
  vite:config   createResolver: [Function: createResolver],
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object]
  vite:config     ],
  vite:config     rollupOptions: {}
  vite:config   },
  vite:config   appType: 'spa',
  vite:config   experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false }
  vite:config } +40ms
vite v3.0.0 building for production...
Unknown input options: build. Allowed options: acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, external, inlineDynamicImports, input, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, maxParallelFileReads, moduleContext, onwarn, perf, plugins, preserveEntrySignatures, preserveModules, 
preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch
✓ 1 modules transformed.
Generated an empty chunk: "index"
dist/index.html   0.50 KiB
Done in 1.12s.

Validations

@sidneifjr sidneifjr changed the title Multi-pages app on build, ignores other files other than index.html Multi-pages app on build, ignores files other than index.html Jul 18, 2022
@sapphi-red
Copy link
Member

Your config is not correct.

  1. build.rollupOptions.build.rollupOptions.input should be build.rollupOptions.input
  2. src/componentes/Accordion/index.html should be src/components/Accordion/index.html (there is an extra e)
export default defineConfig({
  build: {
    outDir: 'dist',

    rollupOptions: {
-      build: {
-        rollupOptions: {
-          input: {
-            index: fileURLToPath(new URL('index.html', import.meta.url)),
-            accordion: fileURLToPath(
-              new URL('src/componentes/Accordion/index.html', import.meta.url) // typo here: componentes
-            ),
-          },
-        },
-      },
+      input: {
+        index: fileURLToPath(new URL('index.html', import.meta.url)),
+        accordion: fileURLToPath(
+          new URL('src/components/Accordion/index.html', import.meta.url)
+        ),
+      },
    },
  },
});

@sapphi-red sapphi-red added invalid This doesn't seem right and removed pending triage labels Jul 19, 2022
@sidneifjr
Copy link
Author

Hello, @sapphi-red; thanks for the help, just noticed that I needed a break from work, before posting the issue.

However, it's nice to point out that the duplicate build.rollupOptions was just a typo when I copied from my repository. Anyhow, thanks again!

@github-actions github-actions bot locked and limited conversation to collaborators Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants