1 | const path = require('path')
|
2 | const webpack = require('webpack')
|
3 | const DefinePlugin = require('webpack').DefinePlugin
|
4 | const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
|
5 | const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
|
6 | const TerserPlugin = require('terser-webpack-plugin')
|
7 |
|
8 | module.exports = {
|
9 | mode: 'production',
|
10 | context: path.resolve(__dirname),
|
11 | output: {
|
12 | path: path.resolve(__dirname, 'dist'),
|
13 | filename: 'mapPromisify.js',
|
14 | library: 'mapPromisify',
|
15 | libraryTarget: 'umd',
|
16 | libraryExport: 'default'
|
17 | },
|
18 | entry: {
|
19 | index: [
|
20 | './src/index.ts'
|
21 | ]
|
22 | },
|
23 | resolve: {
|
24 | extensions: [
|
25 | '.ts'
|
26 | ]
|
27 | },
|
28 | module: {
|
29 | rules: [
|
30 | {
|
31 | test: /\.ts$/,
|
32 | use: [
|
33 |
|
34 | {
|
35 | loader: 'cache-loader',
|
36 | options: {
|
37 | cacheDirectory: path.resolve(__dirname, 'node_modules', '.cache', 'ts-loader'),
|
38 | cacheIdentifier: '56acfc0d'
|
39 | }
|
40 | },
|
41 |
|
42 | {
|
43 | loader: 'thread-loader'
|
44 | },
|
45 |
|
46 | {
|
47 | loader: 'babel-loader'
|
48 | },
|
49 |
|
50 | {
|
51 | loader: 'ts-loader',
|
52 | options: {
|
53 | transpileOnly: true,
|
54 | happyPackMode: true
|
55 | }
|
56 | }
|
57 | ]
|
58 | },
|
59 | ]
|
60 | },
|
61 | optimization: {
|
62 | minimizer: [
|
63 | new TerserPlugin({
|
64 | test: /\.js(\?.*)?$/i,
|
65 | warningsFilter: () => true,
|
66 | extractComments: false,
|
67 | sourceMap: false,
|
68 | cache: true,
|
69 | cacheKeys: defaultCacheKeys => defaultCacheKeys,
|
70 | parallel: true,
|
71 | include: undefined,
|
72 | exclude: undefined,
|
73 | minify: undefined,
|
74 | terserOptions: {
|
75 | output: {
|
76 | comments: /^\**!|@preserve|@license|@cc_on/i
|
77 | },
|
78 | compress: {
|
79 | arrows: false,
|
80 | collapse_vars: false,
|
81 | comparisons: false,
|
82 | computed_props: false,
|
83 | hoist_funs: false,
|
84 | hoist_props: false,
|
85 | hoist_vars: false,
|
86 | inline: false,
|
87 | loops: false,
|
88 | negate_iife: false,
|
89 | properties: false,
|
90 | reduce_funcs: false,
|
91 | reduce_vars: false,
|
92 | switches: false,
|
93 | toplevel: false,
|
94 | typeofs: false,
|
95 | booleans: true,
|
96 | if_return: true,
|
97 | sequences: true,
|
98 | unused: true,
|
99 | conditionals: true,
|
100 | dead_code: true,
|
101 | evaluate: true
|
102 | },
|
103 | mangle: {
|
104 | safari10: true
|
105 | }
|
106 | }
|
107 | })
|
108 | ]
|
109 | },
|
110 | plugins: [
|
111 |
|
112 | new DefinePlugin(
|
113 | {
|
114 | 'process.env': {
|
115 | NODE_ENV: '"production"',
|
116 | BASE_URL: '"/"'
|
117 | }
|
118 | }
|
119 | ),
|
120 | new CaseSensitivePathsPlugin(),
|
121 |
|
122 | new ForkTsCheckerWebpackPlugin(
|
123 | {
|
124 | tslint: true,
|
125 | formatter: 'codeframe',
|
126 | checkSyntacticErrors: true
|
127 | }
|
128 | )
|
129 | ]
|
130 | }
|