-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
42 lines (41 loc) · 1.24 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const slsw = require('serverless-webpack');
const destPath = path.join(__dirname, '.webpack');
module.exports = {
entry: ['source-map-install.js','index.ts'],
output: {
libraryTarget: 'commonjs',
path: slsw.lib.options ? destPath : __dirname,
filename: 'index.js',
},
target: 'node',
node: {
__dirname: false,
__filename: false,
},
mode: slsw.lib.options ? 'production' : 'development',
// we use webpack-node-externals to excludes all node deps.
// You can manually set the externals too.
externals: [nodeExternals({ modulesDir: path.resolve(__dirname, './node_modules') })],
module: {
rules: [
{
test: /\.ts(x?)$/,
loader: 'ts-loader',
exclude: [/\.(test|e2e)\.ts$/],
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
plugins: [new TsconfigPathsPlugin.TsconfigPathsPlugin({ configFile: path.resolve(__dirname, './tsconfig.json') })],
},
plugins: [
new Dotenv({
path: slsw.lib.options ? `./.env.${slsw.lib.options.stage}` : './.env'
})
],
};