Skip to content

Instantly share code, notes, and snippets.

@nirnanaaa
Created September 4, 2016 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nirnanaaa/d7f40deb38f1cf7f931dc7ef0c582bf0 to your computer and use it in GitHub Desktop.
Save nirnanaaa/d7f40deb38f1cf7f931dc7ef0c582bf0 to your computer and use it in GitHub Desktop.
Webpack serverless config
const webpack = require('webpack');
const path = require('path');
const config = require('./config');
module.exports = {
entry: {
login: path.join(__dirname, 'login', 'handler.js'),
email: path.join(__dirname, 'email', 'handler.js'),
graphql: path.join(__dirname, 'back', 'api', 'data', 'handler.js'),
},
resolve: {
root: path.resolve('.'),
extensions: ['', '.js'],
},
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.cache'),
filename: '[name].js',
chunkFilename: '[chunkhash].js',
},
target: 'node',
devtool: 'none',
debug: true,
externals: ['aws-sdk'],
module: {
loaders: [
{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/,
query: {
plugins: ['transform-runtime'],
babelrc: false,
presets: ['es2015', 'stage-0'],
},
},
{
test: /\.json$/,
loaders: ['json'],
include: __dirname,
},
],
},
plugins: [
new webpack.DefinePlugin({
__STAGE__: config.stage,
__REGION__: config.region,
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment