forked from wdr-data/code4maus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.netlify-functions.js
31 lines (28 loc) · 1.12 KB
/
webpack.netlify-functions.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
/* eslint-disable import/no-commonjs */
const webpack = require('webpack');
const fs = require('fs');
const path = require('path');
require('dotenv').config({ silent: true, path: '.env.backend' });
const bucketSuffix = process.env.BRANCH === 'production' ? 'prod' : 'staging';
const bucket = `${process.env.S3_BUCKET_PREFIX}-${bucketSuffix}`;
const backendWebpack = require('./webpack.backend.js');
module.exports = {
entry: () =>
fs
.readdirSync(path.join(__dirname, 'src/backend'))
.filter((file) => !file.match(/^\./) && file.match(/\.js$/))
.reduce((entries, file) => {
const name = file.replace(/\.js$/, '');
entries[name] = `./${name}`;
return entries;
}, {}),
module: backendWebpack.module,
plugins: [
new webpack.DefinePlugin({
'process.env.S3_BUCKET_PROJECTS': JSON.stringify(bucket),
'process.env.ASSET_BASEURL': JSON.stringify(process.env.DEPLOY_PRIME_URL),
'process.env.API_HOST': JSON.stringify(process.env.DEPLOY_PRIME_URL),
}),
],
externals: 'aws-sdk',
};