-
Notifications
You must be signed in to change notification settings - Fork 143
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
Disable sourcemaps for production build #771
Conversation
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh |
webpack.config.babel.js
Outdated
] | ||
})) | ||
const baseStyleRules = (options={}) => { | ||
const { disableExtractToFile, withSourceMap } = options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not deconstruct in the arguments declaration?
From reading webpack-contrib/css-loader#652 it seems they fixed, but according to your test it didn't correct? Also, found this webpack-contrib/less-loader#80 (comment)
what?? why?? 😨 |
webpack.config.babel.js
Outdated
disableExtractToFile || !PRODUCTION_BUILD ? | ||
'style-loader' : | ||
MiniCssExtractPlugin.loader, | ||
...baseStyleLoaders(modules, withSourceMap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will disable the sourcemap for both dist and npm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From reading webpack-contrib/css-loader#652 it seems they fixed, but according to your test it didn't correct?
Yes, I saw the source code with the fix but the problem was still there on upgrading. I couldn't figure out if I need to pass a parameter to the previous loader to make it work.
Also, found this webpack-contrib/less-loader#80 (comment)
Starting with less-loader 4, source maps contain absolute paths now.
what?? why?? 😨
Yes, I read that but from the most recent discussions it seems like they've changed their minds
webpack-contrib/css-loader#886 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will disable the sourcemap for both dist and npm
Oops, will have a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @rfreitas on looking at the full file baseStyleRules
is used in both the configDist
and configNpmLib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I had a default value in place then I did some refactoring and I removed it by mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it makes sense to me now 👍
webpack.config.babel.js
Outdated
disableExtractToFile || !PRODUCTION_BUILD ? | ||
'style-loader' : | ||
MiniCssExtractPlugin.loader, | ||
...baseStyleLoaders(modules, withSourceMap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @rfreitas on looking at the full file baseStyleRules
is used in both the configDist
and configNpmLib
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look good :)
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
# Conflicts: # package-lock.json # package.json
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh |
Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh |
Problem
Currently,
css-loader
when generating source maps, uses absolute paths in thesources
array. These paths are visible in the Chrome developer tools which is not ideal.Solution
This seems to be a known bug in
css-loader
. Please refer to the following issueswebpack-contrib/css-loader#635
webpack-contrib/css-loader#652
webpack-contrib/css-loader#886
There is a PR that fixes part of the issues related to source map paths but it does not seem to fix the problem of absolute paths inside the map
sources
array.webpack-contrib/css-loader#901
Therefore my solution involves disabling
sourceMap
for our NPM build.I also bumped the version of
css-loader
andstyle-loader
Checklist
put
n/a
if item is not relevant to PR changes