-
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
Changes from 2 commits
fd86031
eb1dad0
24b399d
751be11
6ace9df
d9af48b
eb1005d
875e2b3
887628f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,19 +39,20 @@ const baseRules = [ | |
} | ||
]; | ||
|
||
const baseStyleLoaders = (modules=true) => [ | ||
const baseStyleLoaders = (modules, withSourceMap) => [ | ||
//ref: https://github.com/unicorn-standard/pacomo The standard used for naming the CSS classes | ||
//ref: https://github.com/webpack/loader-utils#interpolatename The parsing rules used by webpack | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
sourceMap: true, | ||
modules, | ||
getLocalIdent: (context, localIdentName, localName) => { | ||
const basePath = path.relative(`${__dirname}/src/components`, context.resourcePath) | ||
const baseDirFormatted = path.dirname(basePath).replace('/','-') | ||
return `onfido-sdk-ui-${baseDirFormatted}-${localName}` | ||
} | ||
sourceMap: withSourceMap, | ||
modules: modules ? { | ||
getLocalIdent: (context, localIdentName, localName) => { | ||
const basePath = path.relative(`${__dirname}/src/components`, context.resourcePath) | ||
const baseDirFormatted = path.dirname(basePath).replace('/','-') | ||
return `onfido-sdk-ui-${baseDirFormatted}-${localName}` | ||
} | ||
} : modules | ||
} | ||
}, | ||
{ | ||
|
@@ -62,38 +63,43 @@ const baseStyleLoaders = (modules=true) => [ | |
autoprefixer(), | ||
url({ url: "inline" }) | ||
], | ||
sourceMap: true | ||
sourceMap: withSourceMap | ||
} | ||
}, | ||
{ | ||
loader: 'less-loader', | ||
options: { | ||
sourceMap: true | ||
sourceMap: withSourceMap | ||
} | ||
} | ||
]; | ||
|
||
|
||
|
||
const baseStyleRules = (disableExtractToFile = false) => | ||
[{ | ||
rule: 'exclude', | ||
modules: true | ||
}, | ||
{ | ||
rule: 'include', | ||
modules: false | ||
}].map(({rule, modules})=> ({ | ||
test: /\.(less|css)$/, | ||
[rule]: [`${__dirname}/node_modules`], | ||
use: | ||
[ | ||
disableExtractToFile || !PRODUCTION_BUILD ? | ||
'style-loader' : | ||
MiniCssExtractPlugin.loader, | ||
...baseStyleLoaders(modules) | ||
] | ||
})) | ||
const baseStyleRules = (options={}) => { | ||
const { disableExtractToFile, withSourceMap } = options | ||
return ( | ||
[{ | ||
rule: 'exclude', | ||
modules: true | ||
}, | ||
{ | ||
rule: 'include', | ||
modules: false | ||
}].map(({rule, modules})=> ({ | ||
test: /\.(less|css)$/, | ||
[rule]: [`${__dirname}/node_modules`], | ||
use: | ||
[ | ||
disableExtractToFile || !PRODUCTION_BUILD ? | ||
'style-loader' : | ||
MiniCssExtractPlugin.loader, | ||
...baseStyleLoaders(modules, withSourceMap) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
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.
Yes, I read that but from the most recent discussions it seems like they've changed their minds There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oops, will have a look There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @rfreitas on looking at the full file There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. it makes sense to me now 👍 |
||
] | ||
})) | ||
) | ||
} | ||
|
||
|
||
const WOOPRA_DEV_DOMAIN = 'dev-onfido-js-sdk.com' | ||
const WOOPRA_DOMAIN = 'onfido-js-sdk.com' | ||
|
@@ -327,7 +333,7 @@ const configNpmLib = { | |
module: { | ||
rules: [ | ||
...baseRules, | ||
...baseStyleRules(true) | ||
...baseStyleRules({disableExtractToFile: true, withSourceMap: false}) | ||
] | ||
}, | ||
plugins: [ | ||
|
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?