Skip to content
Permalink
Browse files

Fixing source map issues

  • Loading branch information...
jayair committed May 25, 2019
1 parent 0b97781 commit 8a47ebc8c1b2ed0079ce0387fd25bd327a9e0cc1
@@ -3,10 +3,10 @@
const path = require("path");
const ServerlessWebpack = require("serverless-webpack");

const config = require("./config");
const config = require("./src/config");

function getWebpackConfigPath(servicePath) {
return path.relative(servicePath, __dirname) + "/webpack.config.js";
return path.relative(servicePath, __dirname) + "/src/webpack.config.js";
}

function getConfig(custom, servicePath) {
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,3 @@
module.exports.default = function(source) {
return "import 'source-map-support/register'; " + source;
};
@@ -23,21 +23,35 @@ function resolveEntriesPath(entries) {
return entries;
}

function eslintLoader() {
return {
loader: "eslint-loader",
options: {
cache: ENABLE_CACHING,
baseConfig: eslintConfig
}
};
}

function loaders() {
const loaders = [];
const loaders = {
rules: []
};

if (ENABLE_LINTING) {
loaders.push(eslintLoader());
loaders.rules.push({
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "eslint-loader",
options: {
cache: ENABLE_CACHING,
baseConfig: eslintConfig
}
}
});
}

if (ENABLE_SOURCE_MAPS) {
// Add sourcemap register import to the file
loaders.rules.push({
test: /\.js$/,
include: servicePath,
exclude: /node_modules/,
use: {
loader: path.resolve(__dirname, "sourcemap-register-loader.js")
}
});
}

return loaders;
@@ -69,11 +83,7 @@ module.exports = {
context: __dirname,
// Disable verbose logs
stats: ENABLE_LOGS ? "normal" : "errors-only",
devtool: ENABLE_SOURCE_MAPS
? isLocal
? "cheap-module-eval-source-map"
: "source-map"
: false,
devtool: ENABLE_SOURCE_MAPS ? "source-map" : false,
// Exclude "aws-sdk" since it's a built-in package
externals: ["aws-sdk"],
mode: isLocal ? "development" : "production",
@@ -89,24 +99,16 @@ module.exports = {
modules: [path.resolve(__dirname, "node_modules"), "node_modules"]
},
// Add loaders
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: loaders()
}
]
},
module: loaders(),
// PERFORMANCE ONLY FOR DEVELOPMENT
optimization: isLocal
? {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false
}
// Don't minimize in production
// Large builds can run out of memory
: { minimize: false },
: // Don't minimize in production
// Large builds can run out of memory
{ minimize: false },
plugins: plugins()
};

0 comments on commit 8a47ebc

Please sign in to comment.
You can’t perform that action at this time.