-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
68 lines (63 loc) · 1.51 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const slsw = require('serverless-webpack');
const nodeExternals = require('webpack-node-externals');
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
function resolve(dir) {
return path.join(__dirname, './', dir);
}
module.exports = {
resolve: {
extensions: ['.js', '.ts', '.graphql', '.gql'],
alias: {
'@': resolve('/src'),
},
},
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
entry: slsw.lib.entries,
target: 'node',
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
// Since 'aws-sdk' is not compatible with webpack,
// we exclude all node dependencies
externals: [nodeExternals()],
// Run babel on all .js files and skip those in node_modules
module: {
rules: [
{
test: /\.ts(x?)$/,
use: [
{
loader: 'ts-loader',
},
],
},
{
test: /\.js$/,
loader: 'babel-loader',
include: path.join(__dirname, './'),
exclude: /node_modules/,
},
{
test: /\.graphql$/,
exclude: /node_modules/,
use: [{ loader: 'graphql-import-loader' }],
},
],
},
// Copy generated schema & nexus files
// TODO: Refactor, there's probably a better way to do that :)
plugins: [
new CopyPlugin({
patterns: [
{
from: './src/generated',
to: 'src/src/generated',
toType: 'dir',
},
],
}),
],
};