From c87d044687bdf48b53ed24491d639760cf195a43 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 7 Nov 2018 00:19:10 +0100 Subject: webpack: switch devtool to eval-source-map, use in development mode only --- webpack.config.js | 61 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'webpack.config.js') diff --git a/webpack.config.js b/webpack.config.js index 0bb19e9..cb4dd34 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,31 +1,38 @@ const path = require('path'); -module.exports = { - entry: './src/index.ts', - devtool: 'inline-source-map', - devServer: { - contentBase: './dist' - }, - module: { - rules: [ - { - test: /\.ts$/, - use: 'ts-loader', - exclude: /node_modules/ - }, +module.exports = (env, argv) => { + let config = { + entry: './src/index.ts', + devServer: { + contentBase: './dist' + }, + module: { + rules: [ { - test: /\.(vs|fs)$/, - use: [ - 'raw-loader' - ] - } - ] - }, - resolve: { - extensions: [ ".ts", ".js" ] - }, - output: { - filename: 'bundle.js', - path: path.resolve(__dirname, 'dist') - }, + test: /\.ts$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /\.(vs|fs)$/, + use: [ + 'raw-loader' + ] + } + ] + }, + resolve: { + extensions: [ ".ts", ".js" ] + }, + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, 'dist') + }, + }; + + if (argv.mode === 'development') { + config.devtool = 'eval-source-map'; + } + + return config; }; -- cgit v1.2.3