quasar icon indicating copy to clipboard operation
quasar copied to clipboard

Setting quasar.config.js > build > sourcemap to `true` can't create a separate sourcemap file.

Open dongwa opened this issue 3 years ago • 13 comments

What happened?

I want to test the configuration item of SourceMap. I found that when I set quasar.config.js > build > sourcemap to true, there was no separate sourcemap file in the dist/spa folder as described in the document:

If true, a separate sourcemap file will be created.

image

image

What did you expect to happen?

I don't know whether this is a document description error or quasar CLI behavior mistake, I think they should be consistent

Reproduction URL

https://stackblitz.com/edit/quasarframework-bdqfmg?file=dist/spa/assets/ErrorNotFound.ff16392e.js

How to reproduce?

  1. Using Quasar CLI with vite to create a project
  2. set quasar.config.js > build > sourcemap: true
  3. run quasar build
  4. see files in dist/spa/assets,There is no separate documents mentioned in the map file

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)

Platforms/Browsers

Chrome, Microsoft Edge

Quasar info output

Operating System - Linux(5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.37) - linux/x64
NodeJs - 16.14.2

Global packages
  NPM - 7.17.0
  yarn - 1.22.10
  @quasar/cli - undefined
  @quasar/icongenie - Not installed
  cordova - Not installed

Important local packages
  quasar - 2.9.2 -- Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time
  @quasar/app-vite - 1.1.2 -- Quasar Framework App CLI with Vite
  @quasar/extras - 1.15.4 -- Quasar Framework fonts, icons and animations
  eslint-plugin-quasar - Not installed
  vue - 3.2.40 -- The progressive JavaScript framework for building modern web UI.
  vue-router - 4.1.5
  pinia - Not installed
  vuex - Not installed
  vite - 2.9.15 -- Native-ESM powered web dev build tool
  eslint - 8.24.0 -- An AST-based pattern checker for JavaScript.
  electron - Not installed
  electron-packager - Not installed
  electron-builder - Not installed
  register-service-worker - 1.7.2 -- Script for registering service worker, with hooks
  @capacitor/core - Not installed
  @capacitor/cli - Not installed
  @capacitor/android - Not installed
  @capacitor/ios - Not installed

Quasar App Extensions
  *None installed*

Networking
  Host - quasarframework-bdqfmg

Relevant log output

No response

Additional context

No response

dongwa avatar Oct 10 '22 03:10 dongwa

image

cwforth avatar Oct 21 '22 09:10 cwforth

Relevant line at https://github.com/quasarframework/quasar/blob/56c819d1f32ef191387626f1d5c33485e5dbc04d/app-vite/lib/config-tools.js#L120

The relevant Vite documentation is at https://vitejs.dev/config/build-options.html#build-sourcemap and Quasar is just reflecting the Vite documentation

Sooo.... it seems that Quasar is neither doing what its own docs say nor the Vite docs and is defaulting to "inline" when the config is true. Moreover, there seems to be no possible way of actually passing true through to Vite and therefore no way of generating separate sourcemap file.

Suggested code fix would simply be sourcemap: build.sourcemap ?? false

glorat avatar Jan 15 '23 08:01 glorat

For those that are looking for a quick workaround, one can fortunately do sourcemap: 'true'

By setting it to a string, the quasar code passes it through (due to use of ===) but the vite code will respect the truthiness

glorat avatar Jan 15 '23 08:01 glorat

Relevant line at

https://github.com/quasarframework/quasar/blob/56c819d1f32ef191387626f1d5c33485e5dbc04d/app-vite/lib/config-tools.js#L120

The relevant Vite documentation is at https://vitejs.dev/config/build-options.html#build-sourcemap and Quasar is just reflecting the Vite documentation

Sooo.... it seems that Quasar is neither doing what its own docs say nor the Vite docs and is defaulting to "inline" when the config is true. Moreover, there seems to be no possible way of actually passing true through to Vite and therefore no way of generating separate sourcemap file.

Suggested code fix would simply be sourcemap: build.sourcemap ?? false

You can pr it😊

dongwa avatar Jan 15 '23 08:01 dongwa

Relevant line at https://github.com/quasarframework/quasar/blob/56c819d1f32ef191387626f1d5c33485e5dbc04d/app-vite/lib/config-tools.js#L120

The relevant Vite documentation is at https://vitejs.dev/config/build-options.html#build-sourcemap and Quasar is just reflecting the Vite documentation Sooo.... it seems that Quasar is neither doing what its own docs say nor the Vite docs and is defaulting to "inline" when the config is true. Moreover, there seems to be no possible way of actually passing true through to Vite and therefore no way of generating separate sourcemap file. Suggested code fix would simply be sourcemap: build.sourcemap ?? false

You can pr it😊

Happy to do so

glorat avatar Jan 15 '23 09:01 glorat

This issue is the same as issue #14946, which also has a similar fix #14109

glorat avatar Jan 17 '23 03:01 glorat

Two years on, I couldn't figure out why sourcemaps weren't working and I google myself into the very bug report I wrote then!

Latest workaround is to do sourcemap: 'true' as unknown as boolean, for those using quasar.conf.ts

One of the above two PR's needs to go in to fix this

glorat avatar Jan 20 '25 00:01 glorat

This is still a bug, Can someone merge the pr for it?

subssn21 avatar Mar 30 '25 14:03 subssn21

The clean working PR is at https://github.com/quasarframework/quasar/pull/15276 still waiting to be merged!

glorat avatar Apr 25 '25 14:04 glorat

thanks for workaround! wait for fix merging!

FragsterAt avatar Jun 18 '25 11:06 FragsterAt

I can't reproduce this issue. Using boolean true directly works for me.

nicobao avatar Sep 23 '25 09:09 nicobao

I can still reproduce this as I encountered this just now.

marty0678 avatar Oct 13 '25 06:10 marty0678

Ah that's why my bundled files were so enormous! I wonder how long I've been serving up enormous files to the poor users :(

The workaround I used is:

  
  // instead of setting it here...
  //sourcemap: true,    
  extendViteConf (config) {
    // do it here, and it gets passed to vite directly
    config.build.sourcemap = true
  },

nicksellen avatar Nov 29 '25 21:11 nicksellen