Skip to content

Commit

Permalink
Fix: prevent entry point sourcemap output
Browse files Browse the repository at this point in the history
  • Loading branch information
mwistrand committed May 12, 2019
1 parent ee76f3e commit 62c7a87
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/base.config.ts
Expand Up @@ -180,15 +180,19 @@ export default function webpackConfigFactory(args: any): webpack.Configuration {
new EmitAllPlugin({
legacy: args.legacy,
inlineSourceMaps: false,
assetFilter: (key: string) => {
// Exclude the main.css | main.css.map files generated by webpack, and emit the entry point
// only if src/main.ts is provided by the project.
if (/^main(?!\/)/.test(key)) {
return !/\.css(\.map)?$/.test(key) && args.libEntryPath.endsWith('main.ts');
}

return key.endsWith('.d.ts') || !/\.(css|js)$/.test(key);
}
assetFilter: (() => {
const elementNames = elements.map((element: any) => element.name);
const getElementNameFromKey = (key: string) =>
key.replace(`-${packageJson.version}`, '').replace(/\.(js|css)\.map$/, '');
return (key: string) => {
if (key.endsWith('.map')) {
// Exclude sourcemaps that are generated for the entry paths, as those sourcemaps will be
// added separately to the widget directories.
return !elementNames.includes(getElementNameFromKey(key));
}
return key.endsWith('.d.ts') || !/\.(css|js)$/.test(key);
};
})()
})
]),
module: {
Expand Down

0 comments on commit 62c7a87

Please sign in to comment.