Merge pull request #11892 from vector-im/travis/fix-sourcemaps

Fix indentation on webpack config and make sourcemapped files legible
pull/11893/head
Travis Ralston 2020-01-16 12:01:32 -07:00 committed by GitHub
commit 9a084a6801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 30 deletions

View File

@ -14,7 +14,16 @@ module.exports = (env, argv) => {
argv.mode = "development";
}
const development = {};
if (argv.mode !== "production") {
// This makes the sourcemaps human readable for developers. We use eval-source-map
// because the plain source-map devtool ruins the alignment.
development['devtool'] = 'eval-source-map';
}
return {
...development,
entry: {
"bundle": "./src/vector/index.js",
"indexeddb-worker": "./src/vector/indexeddb-worker.js",
@ -42,6 +51,10 @@ module.exports = (env, argv) => {
},
},
// This fixes duplicate files showing up in chrome with sourcemaps enabled.
// See https://github.com/webpack/webpack/issues/7128 for more info.
namedModules: false,
// Minification is normally enabled by default for webpack in production mode, but
// we use a CSS optimizer too and need to manage it ourselves.
minimize: argv.mode === 'production',
@ -99,7 +112,7 @@ module.exports = (env, argv) => {
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
cacheDirectory: true
}
},
{
@ -297,11 +310,6 @@ module.exports = (env, argv) => {
chunkFilename: "bundles/[hash]/[name].js",
},
// DO NOT enable this option. It makes the source maps all wonky. Instead,
// we end up including the sourcemaps through the loaders which makes them
// more accurate.
//devtool: "source-map",
// configuration for the webpack-dev-server
devServer: {
// serve unwebpacked assets from webapp.