-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
58 lines (56 loc) 路 1.68 KB
/
Copy pathwebpack.config.js
File metadata and controls
58 lines (56 loc) 路 1.68 KB
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
const path = require('path');
const slsw = require('serverless-webpack');
const webpack = require('webpack');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const _ = require('lodash');
const isProd = !slsw.lib.webpack.isLocal;
const entries = _.isEmpty(slsw.lib.entries)
? './src/messenger-entry-function/index.ts'
: slsw.lib.entries;
module.exports = {
entry: entries,
resolve: {
extensions: ['.ts', '.js'],
// webpack defaults to `module` and `main`, but that's
// not really what node.js supports, so we reset it
mainFields: ['main'],
},
devtool: isProd ? 'source-map' : 'cheap-module-eval-source-map',
mode: isProd ? 'production' : 'development',
target: 'node',
node: false,
output: {
libraryTarget: 'commonjs2',
path: path.join(process.cwd(), '.webpack'),
filename: '[name].js',
},
externals: ['aws-sdk'],
module: {
rules: [
{
test: /\.(js|ts)$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
configFile: path.join(__dirname, './.babelrc'),
cacheDirectory: true,
cacheCompression: false,
},
},
],
},
optimization: {
// the below makes sure webpack doesn't touch NODE_ENV
// because the default behavior for webpack is to set NODE_ENV = 'development' | 'production' depending on the mode at compile time
nodeEnv: false,
// minimize: false,
// concatenateModules: false,
},
plugins: [
new webpack.DefinePlugin({
'process.env.IS_OFFLINE': JSON.stringify(!isProd),
'process.env.IS_LOCAL': JSON.stringify(!isProd),
}),
new LodashModuleReplacementPlugin({ paths: true }),
],
};