Skip to content
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

Merged
merged 9 commits into from Sep 2, 2019

Conversation

stefaniacardenas
Copy link
Contributor

@stefaniacardenas stefaniacardenas commented Aug 20, 2019

Problem

Currently, css-loader when generating source maps, uses absolute paths in the sources array. These paths are visible in the Chrome developer tools which is not ideal.

Screen Shot 2019-08-20 at 17 39 35
Screen Shot 2019-08-20 at 17 40 13

Solution

This seems to be a known bug in css-loader. Please refer to the following issues
webpack-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 and style-loader

Checklist

put n/a if item is not relevant to PR changes

  • Have the CHANGELOG, README, MIGRATION, RELEASE_GUIDELINES docs been updated?
  • Have new automated tests been implemented?
  • Have new manual tests been written down?
  • Have tests passed locally?
  • Have any new strings been translated?

@stefaniacardenas stefaniacardenas added the do not merge Do not merge this branch label Aug 20, 2019
@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh

]
}))
const baseStyleRules = (options={}) => {
const { disableExtractToFile, withSourceMap } = options
Copy link
Contributor

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?

@rfreitas
Copy link
Contributor

rfreitas commented Aug 21, 2019

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)

Starting with less-loader 4, source maps contain absolute paths now.

what?? why?? 😨

disableExtractToFile || !PRODUCTION_BUILD ?
'style-loader' :
MiniCssExtractPlugin.loader,
...baseStyleLoaders(modules, withSourceMap)
Copy link
Contributor

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

Copy link
Contributor Author

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)

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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 👍

disableExtractToFile || !PRODUCTION_BUILD ?
'style-loader' :
MiniCssExtractPlugin.loader,
...baseStyleLoaders(modules, withSourceMap)
Copy link
Contributor

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

@stefaniacardenas stefaniacardenas removed the request for review from josokinas August 21, 2019 13:43
@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh

@stefaniacardenas stefaniacardenas removed the do not merge Do not merge this branch label Aug 22, 2019
@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh

Copy link
Contributor

@kopijunkie kopijunkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look good :)

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://staging-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://release-771-pr-onfido-sdk-ui-onfido.surge.sh

@rfreitas
Copy link
Contributor

rfreitas commented Sep 2, 2019

Travis automatic deployment: https://771-pr-onfido-sdk-ui-onfido.surge.sh

@bartzet bartzet merged commit fd973ca into development Sep 2, 2019
@bartzet bartzet deleted the feature/fix-sourcemaps-paths-cx-3789 branch September 2, 2019 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants