Skip to content

Instantly share code, notes, and snippets.

@webhacking
Created September 18, 2019 06:29
Show Gist options
  • Save webhacking/aa1b99fe2e6b028cd87f4ea818a81113 to your computer and use it in GitHub Desktop.
Save webhacking/aa1b99fe2e6b028cd87f4ea818a81113 to your computer and use it in GitHub Desktop.

Revisions

  1. webhacking created this gist Sep 18, 2019.
    42 changes: 42 additions & 0 deletions webpack.config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    // const webpack = require('webpack');
    const path = require('path');
    const nodeExternals = require('webpack-node-externals');
    const slsw = require('serverless-webpack');
    const isLocal = slsw.lib.webpack.isLocal;

    module.exports = {
    mode: isLocal ? 'development' : 'production',
    // entry: slsw.lib.entries,
    entry: './src/main.ts',
    target: 'node',
    devtool: 'source-map',
    externals: [nodeExternals()],
    node: {
    __dirname: true,
    },
    module: {
    rules: [
    {
    test: /\.tsx?$/,
    exclude: /node_modules/,
    loader: 'ts-loader'
    }
    ],
    },
    optimization: {
    removeAvailableModules: false,
    removeEmptyChunks: false,
    splitChunks: false,
    },
    resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
    modules: [path.resolve('./src'), 'node_modules']
    },
    output: {
    libraryTarget: 'commonjs',
    // path: path.join(__dirname, '.webpack'),
    path: path.join(__dirname, 'dist'),
    filename: '[name].js',
    pathinfo: false
    },
    };