In production build CSS Sourcemaps in codesplit chunks are "duplicated", contained in both the .map file and the .js file
See original GitHub issueSteps to reproduce:
- Generate project with vue-router, my exact answers:
? Generate project in current directory? Yes
? Project name vue-app
? Project description A Vue.js project
? Author Jakub Bogucki <jakub.bogucki@xfive.co>
? Vue build runtime
? Install vue-router? Yes
? Use ESLint to lint your code? No
? Setup unit tests No
? Setup e2e tests with Nightwatch? No
- Install dependencies
- edit
src/routes/index.js
:- remove
import HelloWorld from '@/components/HelloWorld'
- replace
component: HelloWorld
withcomponent: () => import('@/components/HelloWorld')
- remove
- build project for production
- open
dist/static/js/0.[hash].js
- format it so you can see it well 😃
- somewhere in the file you should see something like that:
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:15 (10 by maintainers)
Top Results From Across the Web
WebPack sourcemaps confusing (duplicated files)
No webpack:// schema, only one copy of every file, the files actually contain the original source code (kind of important for source maps),...
Read more >Should I Use Source Maps in Production? | CSS-Tricks
A “source map” is a special file that connects a minified/uglified version of an asset (CSS or JavaScript) to the original authored version....
Read more >An Annotated webpack 4 Config for Frontend Web…
Dynamic Code Splitting — I don't want to manually have to define JavaScript chunks in a config file, I want webpack to sort...
Read more >MiniCssExtractPlugin - webpack
This plugin extracts CSS into separate files. It creates a CSS file per JS file which contains CSS. It supports On-Demand-Loading of CSS...
Read more >Reactjs Build Production: Optimize Performance - CopyCat Blog
How to create a Production build production for your React app? ... This build/static folder contains your CSS, JS and media files.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay, so I’ve taken a look.
My observations
app.css
file.0.js
) contains the CSS sourcemap for that chunk’s CSS, and the map file for the code split chunk (e.g.0.js.map
) contains it as well. Not good..js
files that are codesplitted and import a normal.css
file - in other words: webpack / style-loader does this, not Vue or vue-loader.Possible short-term fixes:
/config/index.js
.allChunks: true
in ExtractCSS extracts all css intoapp.css
, even the CSS in codesplit bundles - this also extracts the sourcemap. But that might also be undesirable because I think by default, we do want the CSS to be in the codesplit bundle, but ideally, want the sourcemap for the CSS to be in a separate file.The end goal:
…however, I have no idea if that’s actually possible with the current webpack tools we have.
Will investigate further.
Webpack Experts’ help welcome
This seems to be a tricky one, so if someone out there has a good trick up their sleeve that they can share, please comment / send PR!
Just wondering if this issue is still present when setting allChunks to false.