1 | const TerserPlugin = require('terser-webpack-plugin');
|
2 | const CompressionPlugin = require("compression-webpack-plugin");
|
3 |
|
4 |
|
5 | var webpack = require('webpack');
|
6 |
|
7 | var banner =
|
8 | '/*!\n' +
|
9 | ' * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n' +
|
10 | ' * SPDX-License-Identifier: Apache-2.0\n' +
|
11 | ' */\n\n';
|
12 |
|
13 | module.exports = {
|
14 | entry: {
|
15 | 'amazon-cognito-identity': './src/index.js',
|
16 | 'amazon-cognito-identity.min': './src/index.js',
|
17 | },
|
18 | externals: {
|
19 | crypto: 'crypto',
|
20 | },
|
21 | output: {
|
22 | filename: '[name].js',
|
23 | path: __dirname + '/dist',
|
24 | libraryTarget: 'umd',
|
25 | library: 'AmazonCognitoIdentity',
|
26 | devtoolModuleFilenameTemplate: require('../aws-amplify/webpack-utils')
|
27 | .devtoolModuleFilenameTemplate,
|
28 | },
|
29 | resolve: {
|
30 | extensions: ['.js', '.json'],
|
31 | },
|
32 | mode: 'production',
|
33 | plugins: [
|
34 | new webpack.BannerPlugin({ banner, raw: true }),
|
35 | new CompressionPlugin({
|
36 | include: /\.min\.js$/,
|
37 | })
|
38 | ],
|
39 | optimization: {
|
40 | minimizer: [
|
41 | new TerserPlugin({
|
42 | extractComments: false,
|
43 | terserOptions: {
|
44 | compress: true,
|
45 | sourceMap: true,
|
46 | },
|
47 | include: /\.min\.js$/,
|
48 | })
|
49 | ]
|
50 | },
|
51 | module: {
|
52 | rules: [
|
53 | {
|
54 | test: /\.js?$/,
|
55 | exclude: /node_modules/,
|
56 | use: [
|
57 | 'babel-loader',
|
58 | {
|
59 | loader: 'babel-loader',
|
60 | options: {
|
61 | presets: ['@babel/preset-env'],
|
62 | },
|
63 | },
|
64 | ],
|
65 | },
|
66 | ],
|
67 | },
|
68 | };
|