Replies: 2 comments 6 replies
-
|
@sokra Is this a bug or expected behaviour ? |
Beta Was this translation helpful? Give feedback.
-
|
Copy plugin just copy files and never generate source maps (because it happened before copying), if you need source maps, just copy them too. Where you take your legacy JS file? If you generate them, just enable source map generation and setup copy plugin to copy them too, we can't just generate source maps from raw file (without original mapping). If you need just minimize legacy files and use copy plugin, just use https://github.com/webpack-contrib/copy-webpack-plugin/?tab=readme-ov-file#transformAll, minime them and return array of JS and source maps files |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In our Symfony application, we are using webpack Encore to create the webpack configuration that generates our assets.
For some modern modules we have added entry points e.g.
list_table: './assets/packages/Common/ListTable/Module.js'that we use with twig function{{ encore_entry_script_tags('list_table') }}, but we have a lot of "legacy JS files" in/assets/static/that we simply copy viaCopyWebpackPluginto ourdistdirectory and minify with theTerserWebpackPluginand for these legacy files we use twig function{{ asset('pupil/assets/dist/modules/courses/registration/modals/email.js') }}.The point I want to make from the start, that I can not replace usage of
CopyWebpackPluginwith a dozen entry points.In the output of running
encore production --progresswhich runs webpack,SourceMapDevToolPluginsays it "generated" source maps for the copied legacy files e.g.Unlike with the specified entry points, the
SourceMapDevToolPlugindoes not "attach" these files e.g.#12 123.4 <s> [webpack.Progress] 92% sealing asset processing SourceMapDevToolPlugin list_table.1806adc5.js attached SourceMapI tried to "debug" webpack to understand the underlying issue, but as I have spent already a lot of time with this, so I first try to get an answer here but what I found out is that the "compiler" resolves the copied JS files as
RawSourceobjects without source maps while the entry point JS files are resolved asSourceMapSourceobjects, but no idea how to getSourceMapSourceobjects for the copied JS files...This is the dumped webpack config, reduced to relevant properties only:
As we need source maps for sentry, I want a source map file for each copied JS file in the same directory e.g.
modules/courses/registration/modals/email.2e4d4bd2.js.map.I also noticed that webpack generates numeric bundled JS files for these copied JS files e.g.
1677.a49ac51a.jswith1677.a49ac51a.js.map.1677.a49ac51a.jscontains minified code from our legacy JS files under/assets/static/. I have no idea why these files are generated.What I have tried so far:
devtooltoevalandeval-source-mapmanually, but then I don't get any source maps at all (maybe this option is disallowed for production).TerserPluginconfigoptions.terserOptions.sourceMap = true;, but this doesn't make a difference to not using that.TerserPluginto generate the source maps, but AFAIK there is no possibility option to generate them./assets/static/that we copy with theCopyWebpackPlugin?I really appreciate your help, if you need more information, pls ask and I will add them in the question.
Beta Was this translation helpful? Give feedback.
All reactions