Setting quasar.config.js > build > sourcemap to `true` can't create a separate sourcemap file.
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.


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?
- Using Quasar CLI with vite to create a project
- set quasar.config.js > build > sourcemap: true
- run quasar build
- 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

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
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
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
truethrough 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😊
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
truethrough to Vite and therefore no way of generating separate sourcemap file. Suggested code fix would simply besourcemap: build.sourcemap ?? falseYou can pr it😊
Happy to do so
This issue is the same as issue #14946, which also has a similar fix #14109
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
This is still a bug, Can someone merge the pr for it?
The clean working PR is at https://github.com/quasarframework/quasar/pull/15276 still waiting to be merged!
thanks for workaround! wait for fix merging!
I can't reproduce this issue. Using boolean true directly works for me.
I can still reproduce this as I encountered this just now.
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
},