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

Vite dev canonicalises paths incorrectly when base is specified #6418

Closed
7 tasks done
rbirkby opened this issue Jan 8, 2022 · 0 comments · Fixed by #6419
Closed
7 tasks done

Vite dev canonicalises paths incorrectly when base is specified #6418

rbirkby opened this issue Jan 8, 2022 · 0 comments · Fixed by #6419

Comments

@rbirkby
Copy link

rbirkby commented Jan 8, 2022

Describe the bug

When a base path is specified and vite is run in dev mode (including through 'html' mode middlewares), vite will rewrite the main module path to be in the parent directory rather than as a peer to the entrypoint HTML.

Have repro'd on Windows, MacOS and vite.new

image

Reproduction

https://github.com/rbirkby/vite-canonicalisation-issue

System Info

System:
    OS: macOS 12.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 807.09 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.0 - /usr/local/bin/npm
  Browsers:
    Edge: 97.0.1072.55
    Safari: 15.2

Used Package Manager

npm

Logs

vite:config no config file found. +0ms
(!) "base" option should start with a slash.
(!) "base" option should end with a slash.
  vite:config using resolved config: {
  vite:config   root: '/Users/xxxx/git/vite-canonicalisation-issue',
  vite:config   base: '/abc/',
  vite:config   mode: 'development',
  vite:config   configFile: undefined,
  vite:config   logLevel: undefined,
  vite:config   clearScreen: undefined,
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] }
  vite:config   },
  vite:config   configFileDependencies: [],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: 'abc',
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     server: {}
  vite:config   },
  vite:config   resolve: { dedupe: undefined, alias: [ [Object], [Object] ] },
  vite:config   publicDir: '/Users/xxxx/git/vite-canonicalisation-issue/public',
  vite:config   cacheDir: '/Users/xxxx/git/vite-canonicalisation-issue/node_modules/.vite',
  vite:config   command: 'serve',
  vite:config   isProduction: false,
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html-inline-script-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: '/Users/xxxx/git/vite-canonicalisation-issue/dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  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   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   },
  vite:config   env: { BASE_URL: '/abc/', MODE: 'development', DEV: true, PROD: false },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: true,
  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) {},
  vite:config   createResolver: [Function: createResolver],
  vite:config   optimizeDeps: {
  vite:config     esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
  vite:config   }
  vite:config } +3ms
  vite:deps Hash is consistent. Skipping. Use --force to override. +0ms

  vite v2.7.10 dev server running at:

  > Local: http://localhost:3000/abc/
  > Network: use `--host` to expose

  ready in 69ms.

  vite:time 1.46ms / +0ms
  vite:spa-fallback Rewriting GET / to /index.html +0ms
  vite:time 14.44ms /index.html +28ms
  vite:resolve 1.60ms /@vite/client -> /usr/local/lib/node_modules/vite/dist/client/client.mjs +0ms
  vite:resolve 0.32ms /index.js -> /Users/xxxx/git/vite-canonicalisation-issue/index.js +3ms
  vite:load 1.08ms [fs] /index.js +0ms
  vite:import-analysis 0.21ms [0 imports rewritten] index.js +0ms
  vite:transform 1.75ms /index.js +0ms
  vite:time 4.82ms /index.js +23ms
  vite:load 6.52ms [fs] /@vite/client +3ms
  vite:resolve 0.43ms @vite/env -> /usr/local/lib/node_modules/vite/dist/client/env.mjs +9ms
  vite:import-analysis 3.04ms [1 imports rewritten] /usr/local/lib/node_modules/vite/dist/client/client.mjs +6ms
  vite:transform 3.64ms /@vite/client +6ms
  vite:time 16.18ms /@vite/client +7ms
  vite:load 1.33ms [fs] npm: vite +9ms
  vite:import-analysis 1.33ms [no imports] /usr/local/lib/node_modules/vite/dist/client/env.mjs +5ms
  vite:transform 1.59ms npm: vite +5ms
  vite:cache [memory] npm: vite +0ms
  vite:time 3.26ms npm: vite +8ms

Validations

@poyoho poyoho added inconsistency Inconsistency between dev & build and removed pending triage has pr inconsistency Inconsistency between dev & build labels May 12, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants